ext/yajl/yajl_ext.c in yajl-ruby-0.7.9 vs ext/yajl/yajl_ext.c in yajl-ruby-0.8.0
- old
+ new
@@ -551,11 +551,11 @@
static VALUE rb_yajl_encoder_new(int argc, VALUE * argv, VALUE klass) {
yajl_encoder_wrapper * wrapper;
yajl_gen_config cfg;
VALUE opts, obj, indent;
unsigned char *indentString = NULL, *actualIndent = NULL;
- int beautify = 0;
+ int beautify = 0, htmlSafe = 0;
/* Scan off config vars */
if (rb_scan_args(argc, argv, "01", &opts) == 1) {
Check_Type(opts, T_HASH);
@@ -571,15 +571,18 @@
memcpy(indentString, RSTRING_PTR(indent), RSTRING_LEN(indent));
indentString[RSTRING_LEN(indent)] = '\0';
actualIndent = indentString;
}
}
+ if (rb_hash_aref(opts, sym_html_safe) == Qtrue) {
+ htmlSafe = 1;
+ }
}
if (!indentString) {
indentString = defaultIndentString;
}
- cfg = (yajl_gen_config){beautify, (const char *)indentString};
+ cfg = (yajl_gen_config){beautify, (const char *)indentString, htmlSafe};
obj = Data_Make_Struct(klass, yajl_encoder_wrapper, yajl_encoder_wrapper_mark, yajl_encoder_wrapper_free, wrapper);
wrapper->indentString = actualIndent;
wrapper->encoder = yajl_gen_alloc(&cfg, NULL);
wrapper->on_progress_callback = Qnil;
@@ -883,9 +886,10 @@
sym_allow_comments = ID2SYM(rb_intern("allow_comments"));
sym_check_utf8 = ID2SYM(rb_intern("check_utf8"));
sym_pretty = ID2SYM(rb_intern("pretty"));
sym_indent = ID2SYM(rb_intern("indent"));
+ sym_html_safe = ID2SYM(rb_intern("html_safe"));
sym_terminator = ID2SYM(rb_intern("terminator"));
sym_symbolize_keys = ID2SYM(rb_intern("symbolize_keys"));
#ifdef HAVE_RUBY_ENCODING_H
utf8Encoding = rb_utf8_encoding();