ruby-changes:62705
From: Nobuyoshi <ko1@a...>
Date: Wed, 26 Aug 2020 21:41:53 +0900 (JST)
Subject: [ruby-changes:62705] 445e5548c9 (master): Fixed error messages at non-ascii %string terminator
https://git.ruby-lang.org/ruby.git/commit/?id=445e5548c9 From 445e5548c9da906a2d7a490e660328b2893d07d1 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada <nobu@r...> Date: Wed, 26 Aug 2020 21:36:22 +0900 Subject: Fixed error messages at non-ascii %string terminator diff --git a/parse.y b/parse.y index 9978fb1..4efbd8c 100644 --- a/parse.y +++ b/parse.y @@ -8547,11 +8547,17 @@ parse_percent(struct parser_params *p, const int space_seen, const enum lex_stat https://github.com/ruby/ruby/blob/trunk/parse.y#L8547 quotation: if (c == -1 || !ISALNUM(c)) { term = c; + if (!ISASCII(c)) goto unknown; c = 'Q'; } else { term = nextc(p); if (rb_enc_isalnum(term, p->enc) || !parser_isascii(p)) { + unknown: + pushback(p, term); + c = parser_precise_mbclen(p, p->lex.pcur); + if (c < 0) return 0; + p->lex.pcur += c; yyerror0("unknown type of %string"); return 0; } diff --git a/test/ruby/test_parse.rb b/test/ruby/test_parse.rb index 1e909bce..422a7cb 100644 --- a/test/ruby/test_parse.rb +++ b/test/ruby/test_parse.rb @@ -599,6 +599,8 @@ class TestParse < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_parse.rb#L599 assert_syntax_error('%s', /unterminated quoted string/) assert_syntax_error('%ss', /unknown type/) assert_syntax_error('%z()', /unknown type/) + assert_syntax_error("%\u3042", /unknown type/) + assert_syntax_error("%q\u3042", /unknown type/) end def test_symbol -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/