Skip to content

Commit

Permalink
Fixes #5066. The & operator doesn't work with quoted symbols.
Browse files Browse the repository at this point in the history
We were building a String with the entire bytelist buffer for symbols instead
of proper bounds.  We only saw this issue because :'to_s' goes through Ruby
String processing before being made into a Symbol.  Sort of a weird combo
but it is possible this bad code in Symbol.getName() could be causing other
issues?

[Note: this will only be effective fix for 9.1.  For 9.2 this is already fixed
because we have switched to a completely different way of handling encoded
identifiers.]
  • Loading branch information
enebo committed Feb 28, 2018
1 parent b8e7856 commit 14baf25
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion core/src/main/java/org/jruby/ast/SymbolNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public <T> T accept(NodeVisitor<T> iVisitor) {
* @return Returns a String
*/
public String getName() {
return new String(bytes.unsafeBytes(), EncodingUtils.charsetForEncoding(bytes.getEncoding()));
return new String(bytes.unsafeBytes(), bytes.begin(), bytes.realSize(), EncodingUtils.charsetForEncoding(bytes.getEncoding()));
}

public Encoding getEncoding() {
Expand Down

0 comments on commit 14baf25

Please sign in to comment.