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

ruby-changes:56275

From: Nobuyoshi <ko1@a...>
Date: Sat, 29 Jun 2019 19:16:33 +0900 (JST)
Subject: [ruby-changes:56275] Nobuyoshi Nakada: 792d1deb94 (trunk): Escape control codes in regexp warning message

https://git.ruby-lang.org/ruby.git/commit/?id=792d1deb94

From 792d1deb949e8416d7a76d66771b286d35c8278d Mon Sep 17 00:00:00 2001
From: Nobuyoshi Nakada <nobu@r...>
Date: Sat, 29 Jun 2019 19:07:25 +0900
Subject: Escape control codes in regexp warning message


diff --git a/regerror.c b/regerror.c
index 59cf530..efcfeff 100644
--- a/regerror.c
+++ b/regerror.c
@@ -356,7 +356,8 @@ onig_vsnprintf_with_pattern(UChar buf[], int bufsize, OnigEncoding enc, https://github.com/ruby/ruby/blob/trunk/regerror.c#L356
 	*s++ = *p++;
       }
       else if (!ONIGENC_IS_CODE_PRINT(enc, *p) &&
-	       !ONIGENC_IS_CODE_SPACE(enc, *p)) {
+	       (!ONIGENC_IS_CODE_SPACE(enc, *p) ||
+                ONIGENC_IS_CODE_CNTRL(enc, *p))) {
 	sprint_byte_with_x((char* )bs, (unsigned int )(*p++));
 	len = onigenc_str_bytelen_null(ONIG_ENCODING_ASCII, bs);
         bp = bs;
diff --git a/test/ruby/test_regexp.rb b/test/ruby/test_regexp.rb
index 18a6d4d..6cfd7df 100644
--- a/test/ruby/test_regexp.rb
+++ b/test/ruby/test_regexp.rb
@@ -1124,6 +1124,8 @@ class TestRegexp < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_regexp.rb#L1124
 
     bug8151 = '[ruby-core:53649]'
     assert_warning(/\A\z/, bug8151) { Regexp.new('(?:[\u{33}])').to_s }
+
+    assert_warning(%r[/.*/\Z]) { Regexp.new("[\n\n]") }
   end
 
   def test_property_warn
-- 
cgit v0.10.2


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

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