Diff options
| author | Bryce Kwon <bryce@brycekwon.com> | |
|---|---|---|
| committer | Bryce Kwon <bryce@brycekwon.com> | |
| commit | ||
| parent | ||
| tree | ||
| download | ||
Measure the clamped query without grep -o
grep -o is not in POSIX, while awk's match is.
Diffstat (limited to 'tests/t0204-limits.sh')
| -rwxr-xr-x | tests/t0204-limits.sh | 8 |
1 file changed, 7 insertions, 1 deletion
diff --git a/tests/t0204-limits.sh b/tests/t0204-limits.sh index caf24e9..da50018 100755 --- a/tests/t0204-limits.sh +++ b/tests/t0204-limits.sh @@ -41,7 +41,13 @@ test_expect_success 'an enormous query is clamped, not rejected' ' long=$(awk "BEGIN{s=\"\";for(i=0;i<4000;i++)s=s \"a\"; print s}") && cgit_query "q=$long" >tmp && grep "</html>" tmp && - longest=$(grep -o "aaaa*" tmp | awk "{print length}" | sort -n | tail -1) && + longest=$(awk "{ + while (match(\$0, /aa*/)) { + if (RLENGTH > n) + n = RLENGTH + \$0 = substr(\$0, RSTART + RLENGTH) + } + } END { print n }" tmp) && test "$longest" -eq 512 ' |
