Skip to content

Commit

Permalink
Fix catString to always use UTF-8 and CR_VALID
Browse files Browse the repository at this point in the history
* Java strings are always unicode, so we should encode as UTF-8
  for concatenation.
* The resulting encoded string should always be valid.
  • Loading branch information
headius committed May 8, 2024
1 parent d1a8740 commit 9046cfa
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions core/src/main/java/org/jruby/RubyString.java
Original file line number Diff line number Diff line change
Expand Up @@ -1508,8 +1508,8 @@ public final int catWithCodeRange(ByteList other, int codeRange) {
}

public final RubyString catString(String str) {
ByteList other = encodeBytelist(str, getEncoding());
catWithCodeRange(other, CR_UNKNOWN);
ByteList other = encodeBytelist(str, UTF8);
catWithCodeRange(other, CR_VALID);
return this;
}

Expand Down

0 comments on commit 9046cfa

Please sign in to comment.