diff options
author | Nobuyoshi Nakada <[email protected]> | 2019-06-29 19:07:25 +0900 |
---|---|---|
committer | Nobuyoshi Nakada <[email protected]> | 2019-06-29 19:07:25 +0900 |
commit | 792d1deb949e8416d7a76d66771b286d35c8278d (patch) | |
tree | 6d4563e8dd42408b111fa23808f1c573643410cd | |
parent | 27723b699b5fbad49a7bb16936d5a7d8e80376ba (diff) |
Escape control codes in regexp warning message
-rw-r--r-- | regerror.c | 3 | ||||
-rw-r--r-- | test/ruby/test_regexp.rb | 2 |
2 files changed, 4 insertions, 1 deletions
diff --git a/regerror.c b/regerror.c index 59cf53068e..efcfefffdf 100644 --- a/regerror.c +++ b/regerror.c @@ -356,7 +356,8 @@ onig_vsnprintf_with_pattern(UChar buf[], int bufsize, OnigEncoding enc, *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 18a6d4d7c9..6cfd7df824 100644 --- a/test/ruby/test_regexp.rb +++ b/test/ruby/test_regexp.rb @@ -1124,6 +1124,8 @@ class TestRegexp < Test::Unit::TestCase 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 |