Skip to content

Commit

Permalink
Support four-value syntax for CSS hex color
Browse files Browse the repository at this point in the history
  • Loading branch information
silverwind committed Mar 31, 2024
1 parent 19901a8 commit b599aac
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion css/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ var (
Font = regexp.MustCompile(`^('[a-z \-]+'|[a-z \-]+)$`)
Grayscale = regexp.MustCompile(`^grayscale\(([0-9]{1,2}|100)%\)$`)
GridTemplateAreas = regexp.MustCompile(`^['"]?[a-z ]+['"]?$`)
HexRGB = regexp.MustCompile(`^#([0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})$`)
HexRGB = regexp.MustCompile(`^#([0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$`)
HSL = regexp.MustCompile(`^hsl\([ ]*([012]?[0-9]{1,2}|3[0-5][0-9]|360),[ ]*([0-9]{0,2}|100)\%,[ ]*([0-9]{0,2}|100)\%\)$`)
HSLA = regexp.MustCompile(`^hsla\(([ ]*[012]?[0-9]{1,2}|3[0-5][0-9]|360),[ ]*([0-9]{0,2}|100)\%,[ ]*([0-9]{0,2}|100)\%,[ ]*(1|1\.0|0|(0\.[0-9]+))\)$`)
HueRotate = regexp.MustCompile(`^hue-rotate\(([12]?[0-9]{1,2}|3[0-5][0-9]|360)?\)$`)
Expand Down
4 changes: 4 additions & 0 deletions sanitize_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2028,6 +2028,10 @@ func TestDefaultStyleHandlers(t *testing.T) {
in: `<div style="column-rule-color: #ff00ff;"></div>`,
expected: `<div style="column-rule-color: #ff00ff"></div>`,
},
{
in: `<div style="column-rule-color: #f0ff;"></div>`,
expected: `<div style="column-rule-color: #f0ff"></div>`,
},
{
in: `<div style="column-rule: red;"></div>`,
expected: `<div style="column-rule: red"></div>`,
Expand Down

0 comments on commit b599aac

Please sign in to comment.