ext/yajl/yajl_encode.c in yajl-ruby-0.7.9 vs ext/yajl/yajl_encode.c in yajl-ruby-0.8.0

- old
+ new

@@ -44,20 +44,21 @@ hexBuf[1] = hexchar[c & 0x0F]; } void yajl_string_encode(yajl_buf buf, const unsigned char * str, - unsigned int len) + unsigned int len, unsigned int htmlSafe) { - yajl_string_encode2((const yajl_print_t) &yajl_buf_append, buf, str, len); + yajl_string_encode2((const yajl_print_t) &yajl_buf_append, buf, str, len, htmlSafe); } void yajl_string_encode2(const yajl_print_t print, void * ctx, const unsigned char * str, - unsigned int len) + unsigned int len, + unsigned int htmlSafe) { unsigned int beg = 0; unsigned int end = 0; char hexBuf[7]; hexBuf[0] = '\\'; hexBuf[1] = 'u'; hexBuf[2] = '0'; hexBuf[3] = '0'; @@ -72,9 +73,14 @@ /* case '/': escaped = "\\/"; break; */ case '"': escaped = "\\\""; break; case '\f': escaped = "\\f"; break; case '\b': escaped = "\\b"; break; case '\t': escaped = "\\t"; break; + case '/': + if (htmlSafe) { + escaped = "\\/"; + } + break; default: if ((unsigned char) str[end] < 32) { CharToHex(str[end], hexBuf + 4); escaped = hexBuf; }