summaryrefslogtreecommitdiff
path: root/transcode.c
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-09-04 10:15:34 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-09-04 10:15:34 +0000
commit45c37073038bde691ef12350277cd5a0b7796ec3 (patch)
treea0008d75fa81363442708cdaa98272e426bb8415 /transcode.c
parent1633eb7238776b94a5f162b85f225423174e4c26 (diff)
* 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: svn+ssh://ci.ruby-lang.org/ruby/trunk@19123 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'transcode.c')
-rw-r--r--transcode.c18
1 files changed, 2 insertions, 16 deletions
diff --git a/transcode.c b/transcode.c
index 273a913d31..746892b8d5 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));