Skip to content

Commit 5c6293c

Browse files
committed
Digest#hexdigest should produce US-ASCII strings.
1 parent 8d24996 commit 5c6293c

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

core/src/main/java/org/jruby/ext/digest/RubyDigest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
import java.util.HashMap;
4040
import java.util.Map;
4141

42+
import org.jcodings.specific.USASCIIEncoding;
4243
import org.jruby.Ruby;
4344
import org.jruby.RubyClass;
4445
import org.jruby.RubyFixnum;
@@ -146,7 +147,7 @@ private static ByteList toHex(byte[] val) {
146147
}
147148

148149
private static IRubyObject toHexString(Ruby runtime, byte[] val) {
149-
return RubyString.newStringNoCopy(runtime, ByteList.plain(toHex(val)));
150+
return RubyString.newStringNoCopy(runtime, new ByteList(ByteList.plain(toHex(val)), USASCIIEncoding.INSTANCE));
150151
}
151152

152153
@JRubyMethod(name = "hexencode", required = 1, meta = true)

0 commit comments

Comments
 (0)