1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* parse.y (parser_read_escape): deny extra character escapes.

[ruby-core:27228]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27507 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2010-04-27 01:54:23 +00:00
parent 87ba383aa3
commit 422efe5352
3 changed files with 14 additions and 0 deletions

View file

@ -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.

View file

@ -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 == '?')

View file

@ -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