Skip to content

Commit 3319527

Browse files
committed
Use encoding and CR-aware concatenation
The old `cat` method used here does not consider encodings or code ranges, instead just slamming the given bytes directly into the existing buffer. This causes problem when those bytes or the encoding they came from does not match the existing encoding or code range, leading to issues like #247. The fix here uses a code range-aware method for doing the bytes concatenation, and resolved the related bug. Fixes #247
1 parent 710c1a4 commit 3319527

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/main/java/org/jruby/rack/ext/Input.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import org.jruby.rack.RackEnvironment;
3030
import org.jruby.rack.servlet.RewindableInputStream;
3131
import org.jruby.rack.util.ExceptionUtils;
32+
import org.jruby.util.StringSupport;
3233

3334
/**
3435
* Native (Java) implementation of a Rack input.
@@ -143,7 +144,7 @@ public IRubyObject read(final ThreadContext context, final IRubyObject[] args) {
143144
if ( bytes != null ) {
144145
if ( buffer != null ) {
145146
buffer.clear();
146-
buffer.cat(bytes);
147+
buffer.catWithCodeRange(new ByteList(bytes, false), StringSupport.CR_UNKNOWN);
147148
return buffer;
148149
}
149150
return context.runtime.newString(new ByteList(bytes, false));

0 commit comments

Comments
 (0)