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

UTF-8 BOM can break metadata detection #1823

Closed
KwikOne opened this issue Nov 3, 2013 · 4 comments
Closed

UTF-8 BOM can break metadata detection #1823

KwikOne opened this issue Nov 3, 2013 · 4 comments
Milestone

Comments

@KwikOne
Copy link

KwikOne commented Nov 3, 2013

When trying to install a user script the @name would be ignored and the script name became the script name (ie 181098.user.js became 181098 for a name) and all @includes and @excludes became ignored such that it indicated that the script runs on everything ( * ).
I discovered that the script appeared to be a UTF-8 with BOM (there was a hidden - character in the front of the file (ahead of the // === Userscript === line and the // appeared to be in character position 1 and 2)

Greasemonkey version 1.12

@arantius
Copy link
Collaborator

Cannot reproduce. Please provide an exact file that produces this error. I just wrote this test script which:

$ curl -s http://arantius.com/misc/gm-test/bom-test.user.js | hexdump -C
00000000  ef bb bf 2f 2f 20 3d 3d  55 73 65 72 53 63 72 69  |...// ==UserScri|
00000010  70 74 3d 3d 0a 2f 2f 20  40 6e 61 6d 65 20 20 20  |pt==.// @name   |
00000020  20 20 20 20 20 42 4f 4d  20 54 65 73 74 0a 2f 2f  |     BOM Test.//|
00000030  20 3d 3d 2f 55 73 65 72  53 63 72 69 70 74 3d 3d  | ==/UserScript==|
00000040  0a 0a                                             |..|
00000042

Starts with a valid UTF-8 BOM. And it installs just fine for me, the @name is detected and used.

@KwikOne
Copy link
Author

KwikOne commented Nov 25, 2013

I have the original file, but how do I attach it here? It will only accept an image, not a zip file (since the script is 1.6 million in size). Ah, never mind, the link to the zipped file on dropbox is https://www.dropbox.com/s/nfvdw58t661xkzq/181098-Userscript.zip

@KwikOne
Copy link
Author

KwikOne commented Nov 25, 2013

As for how the script was originally generated to have the invisible (at least to notepad++ but with winmerge it did show up and is how i detected it) character at the front of the file is unknown to me as the script is no longer available on userscript.org. I finally found a good hex editor, and it appears that the file has 2 BOM marks (ef bb bf ef bb bf) prior
greasemonkey-bug-bom

But the strange thing is that in chrome, and tampermonkey it installed just fine

@arantius
Copy link
Collaborator

Thanks for figuring that out. So, reproduced with http://arantius.com/misc/gm-test/181098.user.js which will not successfully parse the @name from the metadata, but is only 110 bytes. Starting:

$ hexdump -C 181098.user.js | head -n 1
00000000  ef bb bf ef bb bf 2f 2f  20 3d 3d 55 73 65 72 53  |......// ==UserS|

The first four bytes are (I think) handled as a BOM, correctly. But the next four break GM, which wants // =UserScript= to be at the start of a line.

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

No branches or pull requests

2 participants