[前][次][番号順一覧][スレッド一覧]

ruby-changes:35016

From: nobu <ko1@a...>
Date: Fri, 8 Aug 2014 01:08:05 +0900 (JST)
Subject: [ruby-changes:35016] nobu:r47098 (trunk): parse.y: fix invalid char in eval

nobu	2014-08-08 01:07:25 +0900 (Fri, 08 Aug 2014)

  New Revision: 47098

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=47098

  Log:
    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]

  Modified files:
    trunk/ChangeLog
    trunk/parse.y
    trunk/test/ruby/test_parse.rb
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 47097)
+++ ChangeLog	(revision 47098)
@@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Fri Aug  8 01:07:10 2014  Nobuyoshi Nakada  <nobu@r...>
+
+	* 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@g...>
 
 	* lib/open3.rb: avoid unnecessary write if stdin_data is empty.
Index: parse.y
===================================================================
--- parse.y	(revision 47097)
+++ parse.y	(revision 47098)
@@ -8266,7 +8266,7 @@ parser_yylex(struct parser_params *parse https://github.com/ruby/ruby/blob/trunk/parse.y#L8266
 
       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;
 	}
 
Index: test/ruby/test_parse.rb
===================================================================
--- test/ruby/test_parse.rb	(revision 47097)
+++ test/ruby/test_parse.rb	(revision 47098)
@@ -657,8 +657,11 @@ x = __ENCODING__ https://github.com/ruby/ruby/blob/trunk/test/ruby/test_parse.rb#L657
   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
 

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]