diff options
author | NARUSE, Yui <nurse@users.noreply.github.com> | 2020-07-31 11:06:58 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-07-31 11:06:58 +0900 |
commit | 8e081fb05c5054fa575dc9852ec1d599707376c9 (patch) | |
tree | 59914b3a3f83ca424174ba8ff9e211592d1e60d2 /ext/json/ext/generator/generator.h | |
parent | e7cf232fa71b3a21094497d18c09ee7f24248bc3 (diff) | |
parent | 8a18cf6a14fc1fae54b3d581434a255c9d98ceea (diff) | |
download | json-8e081fb05c5054fa575dc9852ec1d599707376c9.tar.gz |
Merge pull request #405 from Shopify/escape-slash-2.3.0
Add an option to escape forward slash character
Diffstat (limited to 'ext/json/ext/generator/generator.h')
-rw-r--r-- | ext/json/ext/generator/generator.h | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/ext/json/ext/generator/generator.h b/ext/json/ext/generator/generator.h index c367a62..3ebd622 100644 --- a/ext/json/ext/generator/generator.h +++ b/ext/json/ext/generator/generator.h @@ -49,8 +49,8 @@ static const UTF32 halfMask = 0x3FFUL; static unsigned char isLegalUTF8(const UTF8 *source, unsigned long length); static void unicode_escape(char *buf, UTF16 character); static void unicode_escape_to_buffer(FBuffer *buffer, char buf[6], UTF16 character); -static void convert_UTF8_to_JSON_ASCII(FBuffer *buffer, VALUE string); -static void convert_UTF8_to_JSON(FBuffer *buffer, VALUE string); +static void convert_UTF8_to_JSON_ASCII(FBuffer *buffer, VALUE string, char escape_slash); +static void convert_UTF8_to_JSON(FBuffer *buffer, VALUE string, char escape_slash); static char *fstrndup(const char *ptr, unsigned long len); /* ruby api and some helpers */ @@ -72,6 +72,7 @@ typedef struct JSON_Generator_StateStruct { long max_nesting; char allow_nan; char ascii_only; + char escape_slash; long depth; long buffer_initial_length; } JSON_Generator_State; @@ -150,6 +151,8 @@ static VALUE cState_allow_nan_p(VALUE self); static VALUE cState_ascii_only_p(VALUE self); static VALUE cState_depth(VALUE self); static VALUE cState_depth_set(VALUE self, VALUE depth); +static VALUE cState_escape_slash(VALUE self); +static VALUE cState_escape_slash_set(VALUE self, VALUE depth); static FBuffer *cState_prepare_buffer(VALUE self); #ifndef ZALLOC #define ZALLOC(type) ((type *)ruby_zalloc(sizeof(type))) |