Skip to content
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

Adding ignoreBOM and fatal to TextDecoder #1730

Merged
merged 6 commits into from
Aug 23, 2019

Conversation

Pauan
Copy link
Contributor

@Pauan Pauan commented Aug 21, 2019

Fixes #1729

@alexcrichton
Copy link
Contributor

Looks good to me, thanks!

Could this also include a comment for why the extra options are specified? (in the Rust source, not the generated JS source)

@alexcrichton
Copy link
Contributor

Looks great! I think there are some test failures though?

@Pauan
Copy link
Contributor Author

Pauan commented Aug 22, 2019

@alexcrichton It seems to work fine in Chrome, but is failing in Firefox. I'm investigating it.

@Pauan
Copy link
Contributor Author

Pauan commented Aug 22, 2019

Okay, that took me several hours to debug. It's actually a bug in Firefox:

const decoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
const slice = new Uint8Array([239, 187, 191, 98, 97, 114]);
console.log(decoder.decode(slice) === decoder.decode(slice));

The above code returns true in Chrome but false in Firefox. Basically, if you use the same TextDecoder multiple times, it ignores the ignoreBOM setting.

This has already been reported and fixed (3 days ago), but it is fixed in Firefox 70, so we have to wait for that to be released.

@alexcrichton
Copy link
Contributor

Nice digging! Want to back out the tests and we can land this anyway for the time being?

@Pauan
Copy link
Contributor Author

Pauan commented Aug 22, 2019

@alexcrichton Done.

@alexcrichton alexcrichton merged commit fb0bbc0 into rustwasm:master Aug 23, 2019
@alexcrichton
Copy link
Contributor

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Passing a String to JS removes BOM (FEFF)
2 participants