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

Escape control codes in regexp warning message

This commit is contained in:
Nobuyoshi Nakada 2019-06-29 19:07:25 +09:00
parent 27723b699b
commit 792d1deb94
No known key found for this signature in database
GPG key ID: 4BC7D6DF58D8DF60
2 changed files with 4 additions and 1 deletions

View file

@ -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;

View file

@ -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