-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest-html.sh
More file actions
executable file
·71 lines (56 loc) · 1.59 KB
/
test-html.sh
File metadata and controls
executable file
·71 lines (56 loc) · 1.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/usr/bin/env sh
assert()
{
result="$(echo -e "$2" | ./build/cminify html -)"
if [ "$?" != "0" ]; then
echo 'Crashed on:'
echo "$2"
exit 1
elif [ "$1" != "$result" ]; then
echo 'Error: expected:'
echo "$1"
echo 'got:'
echo "$result"
exit 1
fi
}
input='<script>"<"+"/script>"</script>'
expected='<script>"<\/script>"</script>'
assert "$expected" "$input"
input='<script>3 < /script>/</script>'
expected='<script>3< /script>/</script>'
assert "$expected" "$input"
input='<script>a="</scri" + "pt>"</script>'
expected='<script>a="<\/script>"</script>'
assert "$expected" "$input"
input=' a b '
expected=' a b '
assert "$expected" "$input"
input='</script>; ;'
expected='</script>; ; '
assert "$expected" "$input"
input='<scrIpT TyPe=application/json+ld> { "key" : true } </script>'
expected='<scrIpT TyPe=application/json+ld>{"key":true}</script>'
assert "$expected" "$input"
input='<script type="text/javascript"> { "key" : true } </script>'
expected='<script type=text/javascript>{"key":!0}</script>'
assert "$expected" "$input"
input='<html prop=/>'
expected='<html prop=/>'
assert "$expected" "$input"
input='<html data-yes/>'
expected='<html data-yes>'
assert "$expected" "$input"
input='<html prop="abc"/>'
expected='<html prop=abc>'
assert "$expected" "$input"
input='<html></html>'
expected='<html></html>'
assert "$expected" "$input"
input='<html> <html> </html> <html> </html> </html>'
expected='<html> <html></html> <html></html> </html>'
assert "$expected" "$input"
input='<html> <!---->'
expected='<html> '
assert "$expected" "$input"
echo 'Passed all tests'