diff options
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | parse.y | 2 | ||||
-rw-r--r-- | test/ruby/test_literal.rb | 7 |
3 files changed, 14 insertions, 0 deletions
@@ -1,3 +1,8 @@ +Tue Apr 27 10:54:14 2010 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * parse.y (parser_read_escape): deny extra character escapes. + [ruby-core:27228] + Tue Apr 27 06:20:13 2010 Tanaka Akira <akr@fsij.org> * io.c (select_internal): IO which cbuf is not empty is readable. @@ -5593,6 +5593,7 @@ parser_read_escape(struct parser_params *parser, int flags, goto eof; } if ((c = nextc()) == '\\') { + if (peek('u')) goto eof; return read_escape(flags|ESCAPE_META, encp) | 0x80; } else if (c == -1 || !ISASCII(c)) goto eof; @@ -5608,6 +5609,7 @@ parser_read_escape(struct parser_params *parser, int flags, case 'c': if (flags & ESCAPE_CONTROL) goto eof; if ((c = nextc())== '\\') { + if (peek('u')) goto eof; c = read_escape(flags|ESCAPE_CONTROL, encp); } else if (c == '?') diff --git a/test/ruby/test_literal.rb b/test/ruby/test_literal.rb index 80c8af9312..b4480f725a 100644 --- a/test/ruby/test_literal.rb +++ b/test/ruby/test_literal.rb @@ -52,6 +52,13 @@ class TestRubyLiteral < Test::Unit::TestCase assert_equal "\1", "\1" assert_equal "3", "\x33" assert_equal "\n", "\n" + bug2500 = '[ruby-core:27228]' + %w[c C- M-].each do |pre| + ["u", "x", %w[u{ }]].each do |open, close| + str = "\"\\#{pre}\\#{open}5555#{close}\"" + assert_raise(SyntaxError, "#{bug2500} eval(#{str})") {eval(str)} + end + end end def test_dstring |