-
Notifications
You must be signed in to change notification settings - Fork 387
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
Fix for bad hex strings when using Number
constructor.
#369
Conversation
Can you please provide tests that would fail without your change? Also, can you link to spec text that says that |
I already provided the tests in #366 and that was the only failing test remaining in your latest push. If I can find something concrete in the spec I will link it, but otherwise Node v0.8, old Chrome and Chromium (possibly others) behaviour is different to all others in this respect. So someone's got it right and someone's got it wrong, not consistent. |
You're right about the tests - https://travis-ci.org/paulmillr/es6-shim/jobs/89172994 passes but https://travis-ci.org/paulmillr/es6-shim/jobs/88743727 fails. It's worth noting that this appears to make things consistent, but I do want to know what the spec requires. |
i would guess these
http://www.ecma-international.org/ecma-262/6.0/#sec-literals-numeric-literals
http://www.ecma-international.org/ecma-262/6.0/#sec-number-conversions
So, current environments seem to interpret this as And of course native
That's about as concrete as I can give you. |
@@ -719,6 +719,7 @@ | |||
}; | |||
var nonWS = ['\u0085', '\u200b', '\ufffe'].join(''); | |||
var nonWSregex = new RegExp('[' + nonWS + ']', 'g'); | |||
var isBadHexRegex = new RegExp('^[-+]0x[0-9a-f]+$', 'i'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can just be a literal - /^[\-+]0x[0-9a-f]+$/i
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wasn't sure on the preference of style.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In every language, using literals is preferred over more verbose forms when they're equivalent :-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Understood, but I seem to remember some older environments (probably Opera) had problems with certain literals, I think it was XRegExp
that pointed these out. :)
[Fix] don't parse bad hex strings when using `Number` constructor
Please file a separate issue for |
Ref #366
Node v0.8, old Chrome/Chromium and others.