mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
string.c: no exception on dummy encoding
* string.c (str_compat_and_valid): as scrub does nothing for dummy encoding string now, incompatible encoding is not a matter. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53235 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
10a129cee7
commit
9da8a29760
3 changed files with 14 additions and 10 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
Tue Dec 22 15:21:11 2015 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
|
* string.c (str_compat_and_valid): as scrub does nothing for dummy
|
||||||
|
encoding string now, incompatible encoding is not a matter.
|
||||||
|
|
||||||
Tue Dec 22 14:31:28 2015 Toru Iwase <tietew@tietew.net>
|
Tue Dec 22 14:31:28 2015 Toru Iwase <tietew@tietew.net>
|
||||||
|
|
||||||
* ext/cgi/escape/escape.c (optimized_escape_html): CGI.escapeHTML
|
* ext/cgi/escape/escape.c (optimized_escape_html): CGI.escapeHTML
|
||||||
|
|
13
string.c
13
string.c
|
@ -8639,18 +8639,11 @@ str_compat_and_valid(VALUE str, rb_encoding *enc)
|
||||||
if (cr == ENC_CODERANGE_BROKEN) {
|
if (cr == ENC_CODERANGE_BROKEN) {
|
||||||
rb_raise(rb_eArgError, "replacement must be valid byte sequence '%+"PRIsVALUE"'", str);
|
rb_raise(rb_eArgError, "replacement must be valid byte sequence '%+"PRIsVALUE"'", str);
|
||||||
}
|
}
|
||||||
else if (cr == ENC_CODERANGE_7BIT) {
|
else {
|
||||||
rb_encoding *e = STR_ENC_GET(str);
|
rb_encoding *e = STR_ENC_GET(str);
|
||||||
if (!rb_enc_asciicompat(enc)) {
|
if (cr == ENC_CODERANGE_7BIT ? rb_enc_mbminlen(enc) != 1 : enc != e) {
|
||||||
rb_raise(rb_eEncCompatError, "incompatible character encodings: %s and %s",
|
rb_raise(rb_eEncCompatError, "incompatible character encodings: %s and %s",
|
||||||
rb_enc_name(enc), rb_enc_name(e));
|
rb_enc_name(enc), rb_enc_name(e));
|
||||||
}
|
|
||||||
}
|
|
||||||
else { /* ENC_CODERANGE_VALID */
|
|
||||||
rb_encoding *e = STR_ENC_GET(str);
|
|
||||||
if (enc != e) {
|
|
||||||
rb_raise(rb_eEncCompatError, "incompatible character encodings: %s and %s",
|
|
||||||
rb_enc_name(enc), rb_enc_name(e));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return str;
|
return str;
|
||||||
|
|
|
@ -1642,6 +1642,12 @@ class TestM17N < Test::Unit::TestCase
|
||||||
scrub)
|
scrub)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_scrub_dummy_encoding
|
||||||
|
s = "\u{3042}".encode("iso-2022-jp")
|
||||||
|
assert_equal(s, s.scrub)
|
||||||
|
assert_equal(s, s.force_encoding("iso-2022-jp").scrub("?"))
|
||||||
|
end
|
||||||
|
|
||||||
def test_scrub_bang
|
def test_scrub_bang
|
||||||
str = "\u3042\u3044"
|
str = "\u3042\u3044"
|
||||||
assert_same(str, str.scrub!)
|
assert_same(str, str.scrub!)
|
||||||
|
|
Loading…
Reference in a new issue