-
Notifications
You must be signed in to change notification settings - Fork 30.1k
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
node -c
rejects BOM before #!, but node
accepts it
#27767
Comments
i'd expect a failure if both are present. whether we fail because BOM is invalid js or because a shebang is invalid js seems less relevant. to do this i'd combine them into a stripShebangOrBOM function which operates on the first few bytes of the file all at once so we can't accidentally strip one and then the other. |
(Strictly speaking the BOM is valid - it's parsed as whitespace.) |
that's interesting. i'd still say our logic is wrong here. BOM and shebang only have meaning as the first bytes of the file. |
I made this, if the logic seems alright I'll PR it. 429bf4a |
Fixes nodejs#27767 PR-URL: nodejs#27768 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Fixes nodejs#27767 PR-URL: nodejs#27768 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Version: v12.1.0
The bug is that
check_syntax.js
callstripShebang
beforestripBOM
, but the actual loader calls stripBOM before stripShebag.It's not totally clear which behavior is desired. The original bug which lead to the introduction of
stripBOM
actually had a script with a BOM preceding the#!
, though the test included in that commit doesn't. But unix systems generally require the#!
to be the first two bytes for it to be parsed as an interpreter directive, which means it cannot be preceded by a BOM.The text was updated successfully, but these errors were encountered: