-
-
Notifications
You must be signed in to change notification settings - Fork 904
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[bug] write_to
fails in Nokogiri 1.14.0 when writing to an IO that doesn't implement external_encoding
, such as Zip::OutputStream
#2773
Comments
Thanks for reporting this, and for providing a great test case to reproduce!
The original commit is referenced in the commit you mention. I think it explains pretty well what's going on. We explicitly set the encoding on the IO object so that the intermediate buffers created can match that encoding, and avoid some edge cases related to UTF-16 and BOMs. Edit: also see the subsequent commit b5768c6.
😎 I'll take a look as soon as I can. This seems like it should be pretty easy to work around, but I will want to play with edge cases involving UTF-16 just to make sure it's working right. |
@flavorjones OK, I just assumed that
Glad to see it's documented somewhere at least. |
I've got a fix for CRuby, but JRuby isn't working right with Zip::OutputStream. I'm going to try to get that to work before pushing a PR. |
Fix is going through CI at #2775 |
I hope to cut a patch release this weekend with this fixed. |
See related #3406 in which rubyzip's encoding behavior changed in 2.4.1 (and again in 3.0.dev) that we have no control over. |
Please describe the bug
In Nokogiri 1.14.0,
Node.write_to
callsexternal_encoding
on the output stream. (I'm not sure why it does this as from the IO and Encoding docsexternal_encoding
appears to be only for reading, but whatever.)This fails when the underlying output stream is not an actual IO but only a mostly-IO-like object such as
Zip::OutputStream
.This was not an issue in 1.13.x, so I'm guessing it's related to 795464c.
Help us reproduce what you're seeing
Expected behavior
Actual behavior
Test fails with
Environment
Additional context
Above test requires RubyZip; tested with RubyZip 2.3.2.
The text was updated successfully, but these errors were encountered: