mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
parse.y: zero codepoints
* parse.y (parser_tokadd_utf8): relax restriction to allow zero or more codepoints. fixup r59417. https://github.com/ruby/ruby/commit/7e8b910#commitcomment-25602670 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60766 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
19ae98d5ce
commit
50702d16ab
2 changed files with 8 additions and 2 deletions
4
parse.y
4
parse.y
|
@ -5999,7 +5999,7 @@ parser_tokadd_utf8(struct parser_params *parser, rb_encoding **encp,
|
|||
int c, last = nextc();
|
||||
if (lex_p >= lex_pend) goto unterminated;
|
||||
while (ISSPACE(c = *lex_p) && ++lex_p < lex_pend);
|
||||
do {
|
||||
while (c != close_brace) {
|
||||
if (regexp_literal) tokadd(last);
|
||||
if (!parser_tokadd_codepoint(parser, encp, regexp_literal, TRUE)) {
|
||||
break;
|
||||
|
@ -6008,7 +6008,7 @@ parser_tokadd_utf8(struct parser_params *parser, rb_encoding **encp,
|
|||
if (++lex_p >= lex_pend) goto unterminated;
|
||||
last = c;
|
||||
}
|
||||
} while (c != close_brace);
|
||||
}
|
||||
|
||||
if (c != close_brace) {
|
||||
unterminated:
|
||||
|
|
|
@ -517,6 +517,8 @@ class TestParse < Test::Unit::TestCase
|
|||
assert_syntax_error(src, /:#{__LINE__}: unterminated/o)
|
||||
|
||||
assert_syntax_error('"\u{100000000}"', /invalid Unicode escape/)
|
||||
assert_equal("", eval('"\u{}"'))
|
||||
assert_equal("", eval('"\u{ }"'))
|
||||
|
||||
assert_equal("\x81", eval('"\C-\M-a"'))
|
||||
assert_equal("\177", eval('"\c?"'))
|
||||
|
@ -555,6 +557,10 @@ class TestParse < Test::Unit::TestCase
|
|||
assert_nothing_raised(SyntaxError, bug) do
|
||||
assert_equal(sym, eval(':"foo\u{0}bar"'))
|
||||
end
|
||||
assert_nothing_raised(SyntaxError) do
|
||||
assert_equal(:foobar, eval(':"foo\u{}bar"'))
|
||||
assert_equal(:foobar, eval(':"foo\u{ }bar"'))
|
||||
end
|
||||
end
|
||||
|
||||
def test_parse_string
|
||||
|
|
Loading…
Reference in a new issue