-
-
Notifications
You must be signed in to change notification settings - Fork 279
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
142 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,6 +31,13 @@ func TestSanitizeCSS(t *testing.T) { | |
inputValue: `1 1 1 1`, | ||
expectedValue: `1 1 1 1`, | ||
}, | ||
{ | ||
name: "properties are case corrected", | ||
inputProperty: "Border", | ||
expectedProperty: "border", | ||
inputValue: `1 1 1 1`, | ||
expectedValue: `1 1 1 1`, | ||
}, | ||
{ | ||
name: "expressions are not allowed", | ||
inputProperty: "width", | ||
|
@@ -80,6 +87,13 @@ func TestSanitizeCSS(t *testing.T) { | |
inputValue: `"quotes`, | ||
expectedValue: InnocuousPropertyValue, | ||
}, | ||
{ | ||
name: "font-family non standard names are not allowed", | ||
inputProperty: "font-family", | ||
expectedProperty: "font-family", | ||
inputValue: `foo@bar`, | ||
expectedValue: InnocuousPropertyValue, | ||
}, | ||
{ | ||
name: "obfuscated values are not allowed", | ||
inputProperty: "width", | ||
|
@@ -129,6 +143,34 @@ func TestSanitizeCSS(t *testing.T) { | |
inputValue: `url(vbscript:alert(1337))`, | ||
expectedValue: InnocuousPropertyValue, | ||
}, | ||
{ | ||
name: "background-image absolute FTP URL", | ||
inputProperty: "background-image", | ||
expectedProperty: "background-image", | ||
inputValue: `url("ftp://safe.example.com/img.png")`, | ||
expectedValue: InnocuousPropertyValue, | ||
}, | ||
{ | ||
name: "background-image invalid URL", | ||
inputProperty: "background-image", | ||
expectedProperty: "background-image", | ||
inputValue: `url("` + string([]byte{0x7f}) + `")`, | ||
expectedValue: InnocuousPropertyValue, | ||
}, | ||
{ | ||
name: "background-image invalid prefix", | ||
inputProperty: "background-image", | ||
expectedProperty: "background-image", | ||
inputValue: `/img.png")`, | ||
expectedValue: InnocuousPropertyValue, | ||
}, | ||
{ | ||
name: "background-image invalid sufix", | ||
inputProperty: "background-image", | ||
expectedProperty: "background-image", | ||
inputValue: `url("/img.png`, | ||
expectedValue: InnocuousPropertyValue, | ||
}, | ||
{ | ||
name: "background-image safe URL", | ||
inputProperty: "background-image", | ||
|
@@ -143,6 +185,13 @@ func TestSanitizeCSS(t *testing.T) { | |
inputValue: `url("http://safe.example.com/img.png")`, | ||
expectedValue: `url("http://safe.example.com/img.png")`, | ||
}, | ||
{ | ||
name: "background-image safe mailto URL", | ||
inputProperty: "background-image", | ||
expectedProperty: "background-image", | ||
inputValue: `url("mailto:[email protected]")`, | ||
expectedValue: `url("mailto:[email protected]")`, | ||
}, | ||
{ | ||
name: "background-image multiple URLs", | ||
inputProperty: "background-image", | ||
|