mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* re.c (rb_reg_prepare_re): check string encoding. Oniguruma doesn't
support invalid encoding. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14880 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
7d98c90ef2
commit
f780cdec75
3 changed files with 32 additions and 2 deletions
|
@ -1,3 +1,8 @@
|
|||
Fri Jan 4 14:00:50 2008 Tanaka Akira <akr@fsij.org>
|
||||
|
||||
* re.c (rb_reg_prepare_re): check string encoding. Oniguruma doesn't
|
||||
support invalid encoding.
|
||||
|
||||
Fri Jan 4 10:22:25 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* re.c (rb_reg_search): avoid inner loop for reverse search.
|
||||
|
@ -54,7 +59,7 @@ Fri Jan 4 01:20:21 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
|||
|
||||
Fri Jan 4 00:54:43 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* include/ruby/oniguruma.h: Oniguruma 1.9.1 merged.
|
||||
* include/ruby/oniguruma.h: Oniguruma 5.9.1 merged.
|
||||
|
||||
Fri Jan 4 00:20:47 2008 Tanaka Akira <akr@fsij.org>
|
||||
|
||||
|
|
6
re.c
6
re.c
|
@ -940,6 +940,12 @@ rb_reg_prepare_re(VALUE re, VALUE str)
|
|||
int need_recompile = 0;
|
||||
rb_encoding *enc;
|
||||
|
||||
if (rb_enc_str_coderange(str) == ENC_CODERANGE_BROKEN) {
|
||||
rb_raise(rb_eArgError,
|
||||
"broken %s string",
|
||||
rb_enc_name(rb_enc_get(str)));
|
||||
}
|
||||
|
||||
rb_reg_check(re);
|
||||
/* ignorecase status */
|
||||
if (rb_reg_fixed_encoding_p(re)) {
|
||||
|
|
|
@ -877,7 +877,10 @@ class TestM17N < Test::Unit::TestCase
|
|||
if t != nil
|
||||
assert(t.valid_encoding?) if s1.valid_encoding? && s2.valid_encoding?
|
||||
assert_equal(s2, t)
|
||||
assert_match(/#{Regexp.escape(s2)}/, s1)
|
||||
assert_match(/#{Regexp.escape(a(s2))}/, a(s1))
|
||||
if s1.valid_encoding?
|
||||
assert_match(/#{Regexp.escape(s2)}/, s1)
|
||||
end
|
||||
end
|
||||
else
|
||||
assert_raise(ArgumentError) { s1[s2] }
|
||||
|
@ -1577,6 +1580,10 @@ class TestM17N < Test::Unit::TestCase
|
|||
assert_raise(ArgumentError) { s1.scan(s2) }
|
||||
next
|
||||
end
|
||||
if !s1.valid_encoding?
|
||||
assert_raise(ArgumentError) { s1.scan(s2) }
|
||||
next
|
||||
end
|
||||
r = s1.scan(s2)
|
||||
r.each {|t|
|
||||
assert_equal(s2, t)
|
||||
|
@ -1633,6 +1640,10 @@ class TestM17N < Test::Unit::TestCase
|
|||
assert_raise(ArgumentError) { s1.split(s2) }
|
||||
next
|
||||
end
|
||||
if !s1.valid_encoding?
|
||||
assert_raise(ArgumentError) { s1.split(s2) }
|
||||
next
|
||||
end
|
||||
t = s1.split(s2)
|
||||
t.each {|r|
|
||||
assert(a(s1).include?(a(r)))
|
||||
|
@ -1943,6 +1954,10 @@ class TestM17N < Test::Unit::TestCase
|
|||
lambda { s1.gsub(r2) { s3 } }
|
||||
]
|
||||
].each {|desc, doit|
|
||||
if !s1.valid_encoding?
|
||||
assert_raise(ArgumentError, desc) { doit.call }
|
||||
next
|
||||
end
|
||||
if !str_enc_compatible?(s1, s2)
|
||||
assert_raise(ArgumentError, desc) { doit.call }
|
||||
next
|
||||
|
@ -1993,6 +2008,10 @@ class TestM17N < Test::Unit::TestCase
|
|||
lambda { t=s1.dup; [t, t.gsub!(r2) { s3 }] }
|
||||
]
|
||||
].each {|desc, doit|
|
||||
if !s1.valid_encoding?
|
||||
assert_raise(ArgumentError, desc) { doit.call }
|
||||
next
|
||||
end
|
||||
if !str_enc_compatible?(s1, s2)
|
||||
assert_raise(ArgumentError, desc) { doit.call }
|
||||
next
|
||||
|
|
Loading…
Reference in a new issue