Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

UTF-8 with BOM encoded scripts fail #1440

Closed
diversario opened this issue Aug 2, 2011 · 5 comments
Closed

UTF-8 with BOM encoded scripts fail #1440

diversario opened this issue Aug 2, 2011 · 5 comments

Comments

@diversario
Copy link

If you try to run a UTF-8 with BOM encoded script like

#!/usr/bin/env node

console.log("UTF8!");

it fails with

./test.js: 1: #!/usr/bin/env: not found
./test.js: 3: Syntax error: word unexpected (expecting ")")

if run as executable script or

test.js:1
#!/usr/bin/env
 ^

node.js:134
        throw e; // process.nextTick error, or 'error' event on first tick
        ^
SyntaxError: Unexpected token ILLEGAL

if given to node.
Scripts encoded in ANSI or UTF-8 without BOM work fine.

bnoordhuis added a commit to bnoordhuis/node that referenced this issue Aug 2, 2011
BOMs make V8 raise a 'SyntaxError: Unexpected token ILLEGAL' exception.

Fixes nodejs#1440.
@bnoordhuis
Copy link
Member

@isaacs: can you review 24d4539?

@isaacs
Copy link

isaacs commented Aug 3, 2011

@bnoordhuis The code LGTM, but I can't actually get the tests to fail without the code change. Is git "fixing" the BOM byte or something?

@bnoordhuis
Copy link
Member

The BOM is in the repo:

$ curl -s https://raw.github.com/joyent/node/24d4539/test/fixtures/utf8-bom.json | xxd
0000000: efbb bf34 320a                           ...42.

Do you have locale settings configured in your ~/.gitconfig or .git/config?

@koichik
Copy link

koichik commented Aug 4, 2011

In my environment, test-module-loading.js failed as expected before build.

@bnoordhuis
Copy link
Member

Thanks, @koichik. Merged in ac722bb.

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

No branches or pull requests

4 participants