Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Clear enc2 if BOM strip does not produce anything. Fixes #3674.
Browse files Browse the repository at this point in the history
headius committed Feb 13, 2016
1 parent 8136dd9 commit 64bdd25
Showing 2 changed files with 4 additions and 3 deletions.
6 changes: 4 additions & 2 deletions core/src/main/java/org/jruby/util/io/EncodingUtils.java
Original file line number Diff line number Diff line change
@@ -365,7 +365,7 @@ public static void ioExtIntToEncs(ThreadContext context, IOEncodable encodable,
}

if (internal == null ||
((fmode & OpenFile.SETENC_BY_BOM) == 0) && internal == external) {
((fmode & OpenFile.SETENC_BY_BOM) == 0 && internal == external)) {
encodable.setEnc((defaultExternal && internal != external) ? null : external);
encodable.setEnc2(null);
} else {
@@ -1330,14 +1330,16 @@ static void moreOutputBuffer(ByteList destination, ResizeFunction resizeDestinat
// io_set_encoding_by_bom
public static void ioSetEncodingByBOM(ThreadContext context, RubyIO io) {
Ruby runtime = context.runtime;
Encoding bomEncoding = ioStripBOM(io);
Encoding bomEncoding = ioStripBOM(context, io);

if (bomEncoding != null) {
// FIXME: Wonky that we acquire RubyEncoding to pass these encodings through
IRubyObject theBom = runtime.getEncodingService().getEncoding(bomEncoding);
IRubyObject theInternal = io.internal_encoding(context);

io.setEncoding(runtime.getCurrentContext(), theBom, theInternal, context.nil);
} else {
io.setEnc2(null);
}
}

1 change: 0 additions & 1 deletion test/mri/excludes/TestIO_M17N.rb
Original file line number Diff line number Diff line change
@@ -8,7 +8,6 @@
exclude :test_set_encoding_binmode, "needs investigation"
exclude :test_set_encoding_unsupported, "needs investigation"
exclude :test_stdin_external_encoding_with_reopen, "needs investigation"
exclude :test_strip_bom, "needs investigation"
exclude :test_undef_r, "needs investigation"
exclude :test_undef_w_stateful, "needs investigation"
exclude :test_undef_w_stateless, "needs investigation"

0 comments on commit 64bdd25

Please sign in to comment.