diff --git a/css/handlers.go b/css/handlers.go index f8b8b61..41a00c8 100644 --- a/css/handlers.go +++ b/css/handlers.go @@ -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)?\)$`) diff --git a/sanitize_test.go b/sanitize_test.go index c81aa8b..13feecf 100644 --- a/sanitize_test.go +++ b/sanitize_test.go @@ -2028,6 +2028,10 @@ func TestDefaultStyleHandlers(t *testing.T) { in: `
`, expected: `
`, }, + { + in: `
`, + expected: `
`, + }, { in: `
`, expected: `
`,