Commit 8c02e42
[fix] Encoding.compatible?: check when swapping args
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.1 parent 7745919 commit 8c02e42
1 file changed
Lines changed: 14 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
557 | 557 | | |
558 | 558 | | |
559 | 559 | | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
560 | 565 | | |
561 | 566 | | |
562 | 567 | | |
| |||
619 | 624 | | |
620 | 625 | | |
621 | 626 | | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
622 | 636 | | |
623 | 637 | | |
624 | 638 | | |
| |||
0 commit comments