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

Errors on byte order mark ASCII code 65279 #46

Closed
tysonmatanich opened this issue May 14, 2014 · 13 comments
Closed

Errors on byte order mark ASCII code 65279 #46

tysonmatanich opened this issue May 14, 2014 · 13 comments

Comments

@tysonmatanich
Copy link

On line 87 of map-generator.coffee, prev can contain a byte order mark (ASCII code 65279) which causes JSON.parse(prev) to fail.

Updating to the following, which trims the string, fixes the issue:
JSON.parse(prev.substring(prev.indexOf("{"), prev.lastIndexOf("}") + 1))

@SLaks
Copy link

SLaks commented May 14, 2014

It would be better to explicitly check for & remove a BOM, and continue to fail on other invalid JSON.

https://www.npmjs.org/package/strip-bom

@ai
Copy link
Member

ai commented May 14, 2014

Hm. It is difficult question. If BOM is valid in JSON, you should create issue in JSON ;). If BOM is invaliad you should create issue in you prev map builder tool.

How you generates map with BOM?

@SLaks
Copy link

SLaks commented May 14, 2014

No.

BOMs are an artifact of the UTF8 encoding.
They should appear in files that contain UTF8 bytes, but should be removed when decoding those bytes to a string.
nodejs/node-v0.x-archive#1918

@tysonmatanich
Copy link
Author

I am using Autoprefixer which reads the source map in from a file that can begin with BOM.

@ai
Copy link
Member

ai commented May 14, 2014

@tysonmatanich why your map contains BOM? What tool you use before Autoprefixer, which add BOM to map?

@tysonmatanich
Copy link
Author

Sass via Visual Studio Web Essentials. Might be a Windows thing.

@ai
Copy link
Member

ai commented May 14, 2014

Good time to buy Mac :D

@ai
Copy link
Member

ai commented May 14, 2014

@tysonmatanich without humor I recommend to create issue in Visual Studio Web Essentials. Of cource, we can fix it in PostCSS. But Web Essentials will still generate wrong maps and we will fix and fix all processors one by one.

PostCSS fix will not fix the issue because other processors will fall too on this wrong map.

@ai ai closed this as completed May 14, 2014
@tysonmatanich
Copy link
Author

@SLaks do you know if it's Web Essentials or node-sass is adding the BOM?

@am11
Copy link

am11 commented May 21, 2014

@tysonmatanich, regardless of what node-sass does to map file, its definitely WebEssentials issue. WE does post-processing (especially to fix this libsass issue: sass/libsass#242) and write it back to map file.

I think this is the issue with Sytem.Web.Helpers.Json, which need to be reported at ASP codeplex repo.

I have recently replaced all the occurrences of Sytem.Web.Helpers.Json with JSON.NET. You can try pulling the changes and do the same in your code. Hopefully that fixes the issue. Otherwise, we would need to do something like this to avoid the BOM (which I highly doubt would be required after the JSON.NET change).

@SLaks
Copy link

SLaks commented May 21, 2014

None of that is true; under ordinary circumstances, BOMs never appear in strings.

The BOM is added when writing the strong back to bytes (on disk, when we save the modified JSON to a file)

@am11
Copy link

am11 commented May 21, 2014

None of it? Well this is a WE's issue! ;)

@tysonmatanich, just ignore the rest of my previous comment. This issue is fixed by am11/WebEssentials2013@3a86bb7 via madskristensen/WebEssentials2013#1096. No more BOM..

@tysonmatanich
Copy link
Author

Thanks, I will give it a try.

am11 added a commit to am11/WebEssentials2013 that referenced this issue May 22, 2014
madskristensen added a commit to madskristensen/WebEssentials2013 that referenced this issue May 22, 2014
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

No branches or pull requests

4 participants