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

Invalid assertion for UTF16Encoding with template unicode escapes #911

Closed
isiahmeadows opened this Issue May 5, 2017 · 2 comments

Comments

Projects
None yet
1 participant
@isiahmeadows

isiahmeadows commented May 5, 2017

Something I found while implementing templates for a new parser.

"\u{FFFFFFFF}"
`\u{FFFFFFFF}`

The string is statically determined to be invalid, but the template version is not, due to the most recent changes to the grammar (relaxing the template literal restriction). In 11.8.6.1, it states the following:

  • The TV of TemplateCharacter :: \ EscapeSequence is the SV of EscapeSequence.

In 11.8.4.3, it states the following:

  • The SV of EscapeSequence :: UnicodeEscapeSequence is the SV of the UnicodeEscapeSequence.
  • The SV of UnicodeEscapeSequence :: u { HexDigits } is the UTF16Encoding of the MV of HexDigits.

In 10.1.1, UTF16Encoding makes the following assertion:

  1. Assert: 0 ≤ cp ≤ 0x10FFFF.

This is invalid for templates when parsing the escape \u{FFFFFFFF}, which is perfectly valid within template literals.


Here's how I feel it might be best resolved: change UTF16Encoding to do the following initially:

  1. Assert: cp ≤ 0.
  2. If cp > 0x10FFFF, let cp be 0x10FFFF.
@isiahmeadows

This comment has been minimized.

Show comment
Hide comment
@isiahmeadows

isiahmeadows May 5, 2017

Note: this bug exists independent of the template literal revision.

isiahmeadows commented May 5, 2017

Note: this bug exists independent of the template literal revision.

@isiahmeadows

This comment has been minimized.

Show comment
Hide comment
@isiahmeadows

isiahmeadows May 5, 2017

Actually, the template literal revision fixes this, due to it using CodePoint and NotCodePoint to restrict interpretation.

isiahmeadows commented May 5, 2017

Actually, the template literal revision fixes this, due to it using CodePoint and NotCodePoint to restrict interpretation.

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