-
Notifications
You must be signed in to change notification settings - Fork 431
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
Ignore non-utf8 text in build script output #1583
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow, this is a fun edge-case :D Thanks for the fix!
if let Some(bso) = BuildScriptOutput::new(&line) { | ||
let mut buf = Vec::new(); | ||
while reader | ||
.read_until(b'\n', &mut buf) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add a test that if the output doesn't end with a trailing newline, we still parse the last line of output? (i.e. can you remove the trailing newline from the example output in the test?)
Also, could you add a line of invalid utf-8 to the testdata in the test, to verify this change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
.expect("Cannot read line") | ||
!= 0 | ||
{ | ||
let line = &String::from_utf8_lossy(&buf); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like cargo
actually completely skips any line which isn't utf-8
: https://github.com/rust-lang/cargo/blob/0b84a35c2c7d70df4875a03eb19084b0e7a543ef/src/cargo/core/compiler/custom_build.rs#L566-L569
Can you do the same, rather than trying to parse the line?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perfect, thanks!
Sorry, didn't notice the failed clippy test. |
Sorry, it looks like you need to merge main and then we can get this merged! |
When compiling the latest zstd crate on a German locale in non-release mode on Windows, it outputs localized messages that are not UTF8, causing the compile to fail.
(rebased on main) |
When compiling the latest zstd crate on a German locale in non-release mode on Windows, it outputs localized messages that are not UTF8, causing the compile to fail.