Skip to content
This repository has been archived by the owner on Aug 11, 2022. It is now read-only.

Fix package.json handling to always allow BOM at start #8724

Closed
wants to merge 1 commit into from

Conversation

iarna
Copy link
Contributor

@iarna iarna commented Jun 27, 2015

Fixes #3358

@iarna iarna added this to the 3.0.1 milestone Jun 29, 2015
// Remove byte order marker. This catches EF BB BF (the UTF-8 BOM)
// because the buffer-to-string conversion in `fs.readFileSync()`
// translates it to FEFF, the UTF-16 BOM.
if (content.charCodeAt(0) === 0xFEFF) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This may have a bit of an awkward effect where states involving non-strong content will now throw the "wrong" error ("undefined is not a function"). Are we okay with that? I can see a couple of places in this PR where this seems to be possible.

@iarna iarna force-pushed the iarna/allow-bom branch 4 times, most recently from 4b7d277 to ddde606 Compare July 1, 2015 08:37
@iarna
Copy link
Contributor Author

iarna commented Jul 1, 2015

@zkat: So it turns out that JSON.parse will handle all sorts of data types (it actually just calls toString anything its passed). I've updated this to do the same, so the error messages should now match.

And more importantly, it won't explode w/ buffers.

iarna added a commit that referenced this pull request Jul 1, 2015
@iarna
Copy link
Contributor Author

iarna commented Jul 1, 2015

This landed in master as 28064e5

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

Successfully merging this pull request may close these issues.

2 participants