FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

[fix] Encoding.compatible?: check when swapping args by kares · Pull Request #9345 · jruby/jruby · GitHub

/ jruby Public

[fix] Encoding.compatible?: check when swapping args - #9345

Merged
headius merged 1 commit into
jruby:jruby-10.0from
kares:enc-compatible-10
Mar 31, 2026
Merged

[fix] Encoding.compatible?: check when swapping args#9345
headius merged 1 commit into
jruby:jruby-10.0from
kares:enc-compatible-10

Conversation

kares commented Mar 29, 2026

Copy link
Copy Markdown
Member

When the first argument is not a String (e.g. Regexp) and the second is, areCompatible check swaps objects so that String is first.

However, JRuby also swapped encoding values, which is wrong — CRuby's enc_compatible_latter (encoding.c) only swaps the object/isstr/idx references but keeps enc1/enc2 derived from the original idx values before the swap, so they retain the original argument order.

This caused Encoding.compatible?(regexp_eucjp, string_utf8) to return EUC-JP instead of UTF-8 when the string was ASCII-only.

When the first argument is not a String (e.g. Regexp) and the second
is, areCompatible check swaps objects so that String is first.

However, JRuby also swapped encoding values, which is wrong — CRuby's
enc_compatible_latter (encoding.c) only swaps the object/isstr/idx
references but keeps enc1/enc2 derived from the original idx values
before the swap, so they retain the original argument order.

This caused Encoding.compatible?(regexp_eucjp, string_utf8) to
return EUC-JP instead of UTF-8 when the string was ASCII-only.
kares added this to the JRuby 10.0.5.0 milestone Mar 29, 2026
headius merged commit a780c41 into jruby:jruby-10.0 Mar 31, 2026
206 of 207 checks passed
kares deleted the enc-compatible-10 branch April 7, 2026 08:06
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants


Back | FazBrowse Home | New Git URL