mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
merge revision(s) 57098: [Backport #13042]
re.c: non-regexp name reference * re.c (rb_reg_regsub): other than regexp has no name references. [ruby-core:78686] [Bug #13042] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_3@57349 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
f327b5e23c
commit
f6e44a2a5a
3 changed files with 7 additions and 2 deletions
3
re.c
3
re.c
|
@ -3465,7 +3465,8 @@ rb_reg_regsub(VALUE str, VALUE src, struct re_registers *regs, VALUE regexp)
|
|||
if (name_end < e) {
|
||||
VALUE n = rb_str_subseq(str, (long)(name - RSTRING_PTR(str)),
|
||||
(long)(name_end - name));
|
||||
if (!rb_enc_compatible(RREGEXP(regexp)->src, n) ||
|
||||
if (NIL_P(regexp) ||
|
||||
!rb_enc_compatible(RREGEXP(regexp)->src, n) ||
|
||||
(no = name_to_backref_number(regs, regexp, name, name_end)) < 1) {
|
||||
name_to_backref_error(n);
|
||||
}
|
||||
|
|
|
@ -1483,6 +1483,10 @@ class TestString < Test::Unit::TestCase
|
|||
assert_equal(S("Abc"), S("abc").sub("a") {m = $~; "A"})
|
||||
assert_equal(S("a"), m[0])
|
||||
assert_equal(/a/, m.regexp)
|
||||
bug = '[ruby-core:78686] [Bug #13042] other than regexp has no name references'
|
||||
assert_raise_with_message(IndexError, /oops/, bug) {
|
||||
'hello'.gsub('hello', '\k<oops>')
|
||||
}
|
||||
end
|
||||
|
||||
def test_sub!
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#define RUBY_VERSION "2.3.3"
|
||||
#define RUBY_RELEASE_DATE "2017-01-17"
|
||||
#define RUBY_PATCHLEVEL 233
|
||||
#define RUBY_PATCHLEVEL 234
|
||||
|
||||
#define RUBY_RELEASE_YEAR 2017
|
||||
#define RUBY_RELEASE_MONTH 1
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue