Require \[text]color HTML colors to be well-formed. (#827)

Previously, the parser accepted all letters of the
alphabet for hex digits in HTML colors, and allowed any
number of digits. Now, only well-formed HTML hex colors
are allowed.
This commit is contained in:
Ashish Myles
2017-08-28 23:39:19 -04:00
committed by Kevin Barabash
parent 2fbb2b0128
commit be60165bb1
2 changed files with 15 additions and 7 deletions

View File

@@ -773,7 +773,7 @@ class Parser {
if (!res) {
return null;
}
const match = (/^(#[a-z0-9]+|[a-z]+)$/i).exec(res.text);
const match = (/^(#[a-f0-9]{3}|#[a-f0-9]{6}|[a-z]+)$/i).exec(res.text);
if (!match) {
throw new ParseError("Invalid color: '" + res.text + "'", res);
}