-
Notifications
You must be signed in to change notification settings - Fork 847
Open
Labels
status: needs triageIssues which needs to be reproduced to be verified report.Issues which needs to be reproduced to be verified report.type: fixIssues describing a broken feature.Issues describing a broken feature.
Description
Description
By passing the string is 6633FF that the regex to verify hex color can bypass this validation.
I saw the problem that the validate can be pass with the string about from the regex from the source base of this repository validator.js
Minimal code-snippet showcasing the problem
This is the code from validator.js, that maybe the root cause of this validation.
https://github.com/validatorjs/validator.js/blob/master/src/lib/isHexColor.js
import assertString from './util/assertString';
const hexcolor = /^#?([0-9A-F]{3}|[0-9A-F]{4}|[0-9A-F]{6}|[0-9A-F]{8})$/i;
export default function isHexColor(str) {
assertString(str);
return hexcolor.test(str);
}I think the regex should be implement like this
const hexcolor = /^#{1}([0-9A-F]{3}|[0-9A-F]{4}|[0-9A-F]{6}|[0-9A-F]{8})$/i;
Expected behavior
It should validate the string 6633FF is false


Actual behavior
Metadata
Metadata
Assignees
Labels
status: needs triageIssues which needs to be reproduced to be verified report.Issues which needs to be reproduced to be verified report.type: fixIssues describing a broken feature.Issues describing a broken feature.
