diff options
| author | Vinicius Stock <vinicius.stock@shopify.com> | 2024-10-08 10:47:08 -0400 |
|---|---|---|
| committer | git <svn-admin@ruby-lang.org> | 2024-10-09 14:07:10 +0000 |
| commit | e50754fcfaeb80bef93f043c13895ce386ddb18c (patch) | |
| tree | de915ae686ac19718d18fe7910a5a378292b53f0 /lib | |
| parent | 615a0872167e274d720d7d6bc3fe9a0f34bb44cf (diff) | |
[ruby/prism] Avoid breaking code units offset on binary encoding
https://github.com/ruby/prism/commit/25a4cf6794
Co-authored-by: Kevin Newton <kddnewton@users.noreply.github.com>
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/prism/parse_result.rb | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/prism/parse_result.rb b/lib/prism/parse_result.rb index ae026b42ac..aea5dee9fa 100644 --- a/lib/prism/parse_result.rb +++ b/lib/prism/parse_result.rb @@ -90,7 +90,7 @@ module Prism # concept of code units that differs from the number of characters in other # encodings, it is not captured here. def code_units_offset(byte_offset, encoding) - byteslice = (source.byteslice(0, byte_offset) or raise).encode(encoding) + byteslice = (source.byteslice(0, byte_offset) or raise).encode(encoding, invalid: :replace, undef: :replace) if encoding == Encoding::UTF_16LE || encoding == Encoding::UTF_16BE byteslice.bytesize / 2 |
