Skip to content

Commit

Permalink
Add test for quotes to prevent regression on the ASCII SCRIPT issue
Browse files Browse the repository at this point in the history
  • Loading branch information
buro9 committed Apr 23, 2021
1 parent 73ff1b1 commit aed0bc8
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions sanitize_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1795,3 +1795,43 @@ func TestIssue111ScriptTags(t *testing.T) {
)
}
}

func TestQuotes(t *testing.T) {
p := UGCPolicy()

tests := []test{
{
in: `noquotes`,
expected: `noquotes`,
},
{
in: `"singlequotes"`,
expected: `"singlequotes"`,
},
{
in: `""doublequotes""`,
expected: `""doublequotes""`,
},
}

// These tests are run concurrently to enable the race detector to pick up
// potential issues
wg := sync.WaitGroup{}
wg.Add(len(tests))
for ii, tt := range tests {
go func(ii int, tt test) {
out := p.Sanitize(tt.in)
if out != tt.expected {
t.Errorf(
"test %d failed;\ninput : %s\noutput : %s\nexpected: %s",
ii,
tt.in,
out,
tt.expected,
)
}
wg.Done()
}(ii, tt)
}
wg.Wait()
}

0 comments on commit aed0bc8

Please sign in to comment.