Skip to content

isRgbColor: Invalid rgb percentage strings are matched as valid #2113

@pano9000

Description

@pano9000

Describe the bug
Invalid rgba percentage strings are getting passed as valid

Examples
rgb(5%,5%,5%) helloWorld!
I would expect isRgbColor to return false here, due to the additional string content, after the valid rgb color value, however it currently will return true

The bug is caused by a missing $ at the end of the RegExp:
const rgbColorPercent = /^rgb((([0-9]%|[1-9][0-9]%|100%),){2}([0-9]%|[1-9][0-9]%|100%))/;
const rgbaColorPercent = /^rgba((([0-9]%|[1-9][0-9]%|100%),){3}(0?.\d|1(.0)?|0(.0)?))/;

PR that fixes this will be created in a few moments

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