parse.y: escape all closing parens
* parse.y (simple_re_meta): escape all closing characters, not only round parenthesis. [ruby-core:53578] [Bug #8133] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39858 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
1dfb5bb7fc
commit
ebd8663482
@ -1,3 +1,8 @@
|
|||||||
|
Thu Mar 21 16:48:06 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
|
* parse.y (simple_re_meta): escape all closing characters, not only
|
||||||
|
round parenthesis. [ruby-core:53578] [Bug #8133]
|
||||||
|
|
||||||
Thu Mar 21 13:50:46 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
Thu Mar 21 13:50:46 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
* vm_core.h (UNINITIALIZED_VAR): suppress warnings by clang 4.2.
|
* vm_core.h (UNINITIALIZED_VAR): suppress warnings by clang 4.2.
|
||||||
|
2
parse.y
2
parse.y
@ -5994,7 +5994,7 @@ simple_re_meta(int c)
|
|||||||
switch (c) {
|
switch (c) {
|
||||||
case '$': case '*': case '+': case '.':
|
case '$': case '*': case '+': case '.':
|
||||||
case '?': case '^': case '|':
|
case '?': case '^': case '|':
|
||||||
case ')':
|
case ')': case ']': case '}': case '>':
|
||||||
return TRUE;
|
return TRUE;
|
||||||
default:
|
default:
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -180,9 +180,15 @@ class TestRegexp < Test::Unit::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_source_escaped_paren
|
def test_source_escaped_paren
|
||||||
bug7610 = '[ruby-core:51088]'
|
bug7610 = '[ruby-core:51088] [Bug #7610]'
|
||||||
s = '\(a\)'
|
bug8133 = '[ruby-core:53578] [Bug #8133]'
|
||||||
assert_equal(/#{s}/, eval("%r(#{s})"), bug7610)
|
[
|
||||||
|
["(", ")", bug7610], ["[", "]", bug8133],
|
||||||
|
["{", "}", bug8133], ["<", ">", bug8133],
|
||||||
|
].each do |lparen, rparen, bug|
|
||||||
|
s = "\\#{lparen}a\\#{rparen}"
|
||||||
|
assert_equal(/#{s}/, eval("%r#{lparen}#{s}#{rparen}"), bug)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_source_unescaped
|
def test_source_unescaped
|
||||||
|
Loading…
x
Reference in New Issue
Block a user