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

parse.y: fix invalid char in eval

* parse.y (parser_yylex): fix invalid char in eval, should raise
  an syntax error too, as well as directly coded.
  [ruby-core:64243] [Bug #10117]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47098 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2014-08-07 16:07:25 +00:00
parent fd7a02f960
commit a7c4146d9c
3 changed files with 11 additions and 2 deletions

View file

@ -1,3 +1,9 @@
Fri Aug 8 01:07:10 2014 Nobuyoshi Nakada <nobu@ruby-lang.org>
* parse.y (parser_yylex): fix invalid char in eval, should raise
an syntax error too, as well as directly coded.
[ruby-core:64243] [Bug #10117]
Thu Aug 7 23:25:29 2014 Masaki Matsushita <glass.saga@gmail.com>
* lib/open3.rb: avoid unnecessary write if stdin_data is empty.

View file

@ -8266,7 +8266,7 @@ parser_yylex(struct parser_params *parser)
default:
if (!parser_is_identchar()) {
rb_compile_error(PARSER_ARG "Invalid char `\\x%02X' in expression", c);
compile_error(PARSER_ARG "Invalid char `\\x%02X' in expression", c);
goto retry;
}

View file

@ -657,8 +657,11 @@ x = __ENCODING__
end
def test_invalid_char
bug10117 = '[ruby-core:64243] [Bug #10117]'
invalid_char = /Invalid char `\\x01'/
x = 1
assert_equal(1, eval("\x01x"))
assert_in_out_err(%W"-e \x01x", "", [], invalid_char, bug10117)
assert_syntax_error("\x01x", invalid_char, bug10117)
assert_equal(nil, eval("\x04x"))
end