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

Handle correctly octal or hex values located in template strings #29

Merged
merged 3 commits into from
Apr 5, 2024

Conversation

ypapouski
Copy link
Contributor

@ypapouski ypapouski commented Apr 3, 2024

The PR fixes these two issues:
https://github.com/surfly/it/issues/4752
https://github.com/surfly/it/issues/4815

In general the PR fixes these two corner cases with template strings:

  1. tag()`template string with octal or hex value`
  2. String.raw`template string with octal or hex value`

@ypapouski ypapouski changed the title Extend context with 'TaggedTemplate' for 'parseParenthesizedExpressio… Handle correctly octal or hex values located in template strings Apr 3, 2024
@ypapouski ypapouski marked this pull request as ready for review April 3, 2024 16:37
"(function() { return () => {}; })()`'\\00a0'`",
"(function tag() {})`'\\00a0'`",
"(function() {})`'\\00a0'`",
'String.raw`{\rtf1adeflang1025ansiansicpg1252\\uc1`;'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like the case from the ticket is still not working.
Tested on https://meriyah.github.io/meriyah/

String.raw`{\rtf1\adeflang1025\ansi\ansicpg1252\uc1`;

// > [1:49]: Invalid hexadecimal escape sequence

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually none of my examples are working in this app and I believe it's because that my fix is available only in version v4.4.2. The version of https://meriyah.github.io/meriyah/ is v4.3.4
Screenshot 2024-04-04 at 11 31 28

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right, online version of the parser is outdated.

But the test cases are actually working in old versions, that caused the confusion:

// string from the tests - parsed before the fix
String.raw`{\rtf1adeflang1025ansiansicpg1252\\uc1`;

// string from the ticket - only works after the fix
String.raw`{\rtf1\adeflang1025\ansi\ansicpg1252\uc1`;

Can we add second string to the tests?

Copy link
Contributor Author

@ypapouski ypapouski Apr 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aha, I see your confusion and it's tricky indeed! I must have added an additional '\' because otherwise a js string can't be created:
Screenshot 2024-04-04 at 18 47 16

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not as a regular string, but String.raw actually accepts it.
image

@ypapouski ypapouski merged commit 92456cc into master Apr 5, 2024
0 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants