ruby icon indicating copy to clipboard operation
ruby copied to clipboard

Make String#rstrip{,!} raise Encoding::CompatibilityError for broken coderange

Open jeremyevans opened this issue 1 year ago • 0 comments

It's questionable whether we want to allow rstrip to work for strings where the broken coderange occurs before the trailing whitespace and not after, but this approach is probably simpler, and I don't think users should expect string operations like rstrip to work on broken strings.

In some cases, this changes rstrip to raise Encoding::CompatibilityError instead of ArgumentError. However, as the problem is related to an encoding issue in the receiver, and due not due to an issue with an argument, I think Encoding::CompatibilityError is the more appropriate error.

Fixes [Bug #18931]

jeremyevans avatar Aug 24 '22 19:08 jeremyevans