Skip to content

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

Closed
@akosthekiss

Description

@akosthekiss

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).

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugUndesired behaviourparserRelated to the JavaScript parser

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions