From d96eba12c24c71fb75a41ff4fcb7ca7ee1e46f91 Mon Sep 17 00:00:00 2001 From: nobu Date: Fri, 11 Aug 2017 02:05:24 +0000 Subject: [PATCH] re.c: options for sub-regexp * re.c (rb_reg_to_s): needs embedded options to check syntax of sub-regexp. [ruby-core:82328] [Bug #13798] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59574 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- re.c | 2 +- test/ruby/test_regexp.rb | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/re.c b/re.c index d0aa2a792e..55eea5a81e 100644 --- a/re.c +++ b/re.c @@ -606,7 +606,7 @@ rb_reg_to_s(VALUE re) ++ptr; len -= 2; - err = onig_new(&rp, ptr, ptr + len, ONIG_OPTION_DEFAULT, + err = onig_new(&rp, ptr, ptr + len, options, enc, OnigDefaultSyntax, NULL); onig_free(rp); ruby_verbose = verbose; diff --git a/test/ruby/test_regexp.rb b/test/ruby/test_regexp.rb index 2c4c9709f7..549b21c84e 100644 --- a/test/ruby/test_regexp.rb +++ b/test/ruby/test_regexp.rb @@ -74,6 +74,12 @@ class TestRegexp < Test::Unit::TestCase end end + def test_to_s_extended_subexp + re = /#\g#{"\n"}/x + re = /#{re}/ + assert_warn('', '[ruby-core:82328] [Bug #13798]') {re.to_s} + end + def test_union assert_equal :ok, begin Regexp.union(