Many of Oniguruma functions need valid encoding strings
This commit is contained in:
parent
02b70256b5
commit
6b4f8945d6
Notes:
git
2024-11-26 02:46:54 +00:00
3
string.c
3
string.c
@ -3076,7 +3076,8 @@ rb_str_subpos(VALUE str, long beg, long *lenp)
|
||||
}
|
||||
if (beg < 0) {
|
||||
if (len > -beg) len = -beg;
|
||||
if (-beg * rb_enc_mbmaxlen(enc) < blen / 8) {
|
||||
if ((ENC_CODERANGE(str) == ENC_CODERANGE_VALID) &&
|
||||
(-beg * rb_enc_mbmaxlen(enc) < blen / 8)) {
|
||||
beg = -beg;
|
||||
while (beg-- > len && (e = rb_enc_prev_char(s, e, e, enc)) != 0);
|
||||
p = e;
|
||||
|
@ -169,6 +169,10 @@ CODE
|
||||
assert_equal(nil, S("\u{3042 3044 3046}")[RbConfig::LIMITS["LONG_MIN"], 1])
|
||||
end
|
||||
|
||||
def test_AREF_invalid_encoding
|
||||
assert_equal(S("\x80"), S("A"*39+"\x80")[-1, 1])
|
||||
end
|
||||
|
||||
def test_ASET # '[]='
|
||||
s = S("FooBar")
|
||||
s[0] = S('A')
|
||||
|
Loading…
x
Reference in New Issue
Block a user