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

Incorrect regexp character class handling with \uNNNN and \xNN code points #962

Closed
akosthekiss opened this issue Mar 11, 2016 · 1 comment
Labels
bug Undesired behaviour parser Related to the JavaScript parser

Comments

@akosthekiss
Copy link
Member

Test code:

function re_test (pattern, string)
{
  var r = new RegExp (pattern);
  print ("'" + pattern + "' ~ '" + string + "' => '" + (new RegExp (pattern)).exec(string) + "'");
}

re_test ("[\\u0020]", "u");
re_test ("[\\u0020]", " ");
re_test ("[\\u0020]", "x");

re_test ("[\\x20]", "u");
re_test ("[\\x20]", " ");
re_test ("[\\x20]", "x");

Output:

'[\u0020]' ~ 'u' => 'u'
'[\u0020]' ~ ' ' => ' '
'[\u0020]' ~ 'x' => 'null'
'[\x20]' ~ 'u' => 'null'
'[\x20]' ~ ' ' => ' '
'[\x20]' ~ 'x' => 'x'

The first and last results are incorrect.

This could either be fixed in #961 or handled separately (in which case a regtest could be added to the test suite as well, based on the above).

@akosthekiss akosthekiss added bug Undesired behaviour parser Related to the JavaScript parser labels Mar 11, 2016
akosthekiss added a commit to akosthekiss/jerryscript that referenced this issue Mar 19, 2016
Also adding a regression test covering the issue.

Fixes jerryscript-project#962

JerryScript-DCO-1.0-Signed-off-by: Akos Kiss [email protected]
akosthekiss added a commit to akosthekiss/jerryscript that referenced this issue Mar 20, 2016
Currently, if a regexp contains a character class and that
character class contains a hex-specified code point -- either
\uNNNN or \xNN --, then the character 'u' or 'x' is added to the
character class as well. This patch fixes the error and also adds
a regression test covering the issue.

Fixes jerryscript-project#962

JerryScript-DCO-1.0-Signed-off-by: Akos Kiss [email protected]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Undesired behaviour parser Related to the JavaScript parser
Projects
None yet
Development

No branches or pull requests

1 participant