diff options
| author | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-09-04 10:15:34 +0000 |
|---|---|---|
| committer | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-09-04 10:15:34 +0000 |
| commit | 61f8b79aee55fe6eb56cc1f68a35ee42675d0320 (patch) | |
| tree | a0008d75fa81363442708cdaa98272e426bb8415 /transcode.c | |
| parent | 970524f9fa95fef27eeb3f218e182cef4065855c (diff) | |
| download | ruby-61f8b79aee55fe6eb56cc1f68a35ee42675d0320.tar.gz ruby-61f8b79aee55fe6eb56cc1f68a35ee42675d0320.tar.xz ruby-61f8b79aee55fe6eb56cc1f68a35ee42675d0320.zip | |
* include/ruby/encoding.h (ECONV_INVALID_IGNORE): removed because
it tend to cause security problem. If the behaviour is really
required, ECONV_INVALID_REPLACE with empty string can be used.
For example, CVE-2006-2313, CVE-2008-1036, [ruby-core:15645]
(ECONV_UNDEF_IGNORE): ditto.
* transcode.c (rb_econv_convert): follow the above change.
(econv_opts): ditto.
(Init_transcode): ditto.
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@19123 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'transcode.c')
| -rw-r--r-- | transcode.c | 18 |
1 files changed, 2 insertions, 16 deletions
diff --git a/transcode.c b/transcode.c index 273a913d3..746892b8d 100644 --- a/transcode.c +++ b/transcode.c @@ -1286,10 +1286,7 @@ rb_econv_convert(rb_econv_t *ec, ret == econv_incomplete_input) { /* deal with invalid byte sequence */ /* todo: add more alternative behaviors */ - if (ec->flags&ECONV_INVALID_IGNORE) { - goto resume; - } - else if (ec->flags&ECONV_INVALID_REPLACE) { + if (ec->flags&ECONV_INVALID_REPLACE) { if (output_replacement_character(ec) == 0) goto resume; } @@ -1299,10 +1296,7 @@ rb_econv_convert(rb_econv_t *ec, /* valid character in source encoding * but no related character(s) in destination encoding */ /* todo: add more alternative behaviors */ - if (ec->flags&ECONV_UNDEF_IGNORE) { - goto resume; - } - else if (ec->flags&ECONV_UNDEF_REPLACE) { + if (ec->flags&ECONV_UNDEF_REPLACE) { if (output_replacement_character(ec) == 0) goto resume; } @@ -2009,9 +2003,6 @@ econv_opts(VALUE opt) v = rb_hash_aref(opt, sym_invalid); if (NIL_P(v)) { } - else if (v==sym_ignore) { - options |= ECONV_INVALID_IGNORE; - } else if (v==sym_replace) { options |= ECONV_INVALID_REPLACE; v = rb_hash_aref(opt, sym_replace); @@ -2022,9 +2013,6 @@ econv_opts(VALUE opt) v = rb_hash_aref(opt, sym_undef); if (NIL_P(v)) { } - else if (v==sym_ignore) { - options |= ECONV_UNDEF_IGNORE; - } else if (v==sym_replace) { options |= ECONV_UNDEF_REPLACE; } @@ -3314,10 +3302,8 @@ Init_transcode(void) rb_define_method(rb_cEncodingConverter, "replacement", econv_get_replacement, 0); rb_define_method(rb_cEncodingConverter, "replacement=", econv_set_replacement, 1); rb_define_const(rb_cEncodingConverter, "INVALID_MASK", INT2FIX(ECONV_INVALID_MASK)); - rb_define_const(rb_cEncodingConverter, "INVALID_IGNORE", INT2FIX(ECONV_INVALID_IGNORE)); rb_define_const(rb_cEncodingConverter, "INVALID_REPLACE", INT2FIX(ECONV_INVALID_REPLACE)); rb_define_const(rb_cEncodingConverter, "UNDEF_MASK", INT2FIX(ECONV_UNDEF_MASK)); - rb_define_const(rb_cEncodingConverter, "UNDEF_IGNORE", INT2FIX(ECONV_UNDEF_IGNORE)); rb_define_const(rb_cEncodingConverter, "UNDEF_REPLACE", INT2FIX(ECONV_UNDEF_REPLACE)); rb_define_const(rb_cEncodingConverter, "PARTIAL_INPUT", INT2FIX(ECONV_PARTIAL_INPUT)); rb_define_const(rb_cEncodingConverter, "OUTPUT_FOLLOWED_BY_INPUT", INT2FIX(ECONV_OUTPUT_FOLLOWED_BY_INPUT)); |
