diff options
author | Peter Zhu <[email protected]> | 2022-09-27 14:54:09 -0400 |
---|---|---|
committer | Peter Zhu <[email protected]> | 2022-09-28 09:05:23 -0400 |
commit | 28a572f8bffe54226a7ad3fae814c1c92b5036e6 (patch) | |
tree | 8d7149c66727c97c4f6366e3de53a6ef047c84b2 /string.c | |
parent | 6f8d17e43c7b9b3b8bf42df0ef1ca085080b65f0 (diff) |
Fix bug when slicing a string with broken encoding
Commit aa2a428 introduced a bug where non-embedded string slices copied
the encoding of the original string. If the original string had a broken
encoding but the slice has valid encoding, then the slice would be
incorrectly marked as broken encoding.
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/6456
Diffstat (limited to 'string.c')
-rw-r--r-- | string.c | 1 |
1 files changed, 1 insertions, 0 deletions
@@ -2811,6 +2811,7 @@ str_subseq(VALUE str, long beg, long len) } else { str2 = str_new_shared(rb_cString, str); + ENC_CODERANGE_CLEAR(str2); RSTRING(str2)->as.heap.ptr += beg; if (RSTRING(str2)->as.heap.len > len) { RSTRING(str2)->as.heap.len = len; |