Skip to content

JavaScript: false positive with unicode sets for character classes that contain brackets #18854

@ryzokuken

Description

@ryzokuken

Description of the false positive

Earlier, a colleague of mine filed #18721 regarding adding support for the v flag. That was implemented but it seems like there's some false positives without properly handling of the set operations.

More specifically, the regex below fails with the ID js/regex/duplicate-in-character-class since it believes [\S--[\[\]]] is a character class that contains brackets ([]) twice.

Code samples or links to source code

const regex = /\b(?:https?:\/\/|mailto:|www\.)(?:[\S--[\p{P}<>]]|\/|[\S--[\[\]]]+[\S--[\p{P}<>]])+|\b[\S--[@\p{Ps}\p{Pe}<>]]+@([\S--[\p{P}<>]]+(?:\.[\S--[\p{P}<>]]+)+)/gmv;

at https://github.com/mozilla/pdf.js/blob/fef706233d6870ddb01ac2131a2ee157262187a4/web/autolinker.js#L101-L101.

URL to the alert on GitHub code scanning (optional)

https://github.com/mozilla/pdf.js/security/code-scanning/1003

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions