forked from DOMjudge/domjudge-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun_html_validation.sh
executable file
·136 lines (121 loc) · 3 KB
/
run_html_validation.sh
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
#!/bin/sh
#
# Cronjob script to automatically run HTML validation of webpages
# on an live, publicly accessible DOMjudge installation.
set -e
#DEBUG=1
# Optionally specify a user and password when the web interface is
# password protected:
#USER=jury
#PASS=passwordhere
LIVESYSTEMDIR=~/system
LIVEURLPREFIX="https://${USER:+$USER:$PASS@}www.domjudge.org/domjudge/"
VNUCHECKER=~/vnu_html_checker/vnu.jar
[ "$DEBUG" ] && set -x
quiet()
{
if [ "$DEBUG" ]; then
"$@"
else
"$@" > /dev/null 2>&1
fi
}
TEMPDIR=$(mktemp -d /tmp/dj_html_validate-XXXXXX)
cd ~
# Validate DOMjudge webpages running from uptodate git checkout
# (we cannot use a fresh checkout due to missing website config)
cd $LIVESYSTEMDIR && git pull -q --rebase --autostash
URLS='
.
public/
public/problems.php
public/team.php?id=2
team
team/clarification.php
team/clarification.php?id=137
team/problems.php
team/scoreboard.php
team/scoreboard.php?categoryid[]=1&filter=filter
team/submission_details.php?id=998
team/submission_details.php?id=1163
team/team.php?id=2
jury/
jury/auditlog.php
jury/balloons.php
jury/checkconfig.php
jury/check_judgings.php
jury/clarification.php
jury/clarification.php?id=107
jury/clarifications.php
jury/config.php
jury/contest.php?cmd=add
jury/contest.php?id=2
jury/contests.php
jury/edit_source.php?id=1&rank=0
jury/executables.php
jury/executable.php?id=c
jury/genpasswds.php
jury/impexp.php
jury/impexp_contestyaml.php
jury/index.php
jury/internal_errors.php
jury/internal_error.php?id=1
jury/judgehost.php?id=judgehost1
jury/judgehosts.php?cmd=edit&referrer=judgehosts.php
jury/judgehosts.php
jury/judgehost_restriction.php?cmd=add
jury/judgehost_restriction.php?id=1
jury/judgehost_restrictions.php
jury/language.php?cmd=add
jury/language.php?id=c
jury/languages.php
jury/problem.php?id=7
jury/problem.php?id=7&cmd=edit
jury/problems.php
jury/refresh_cache.php
jury/rejudging.php?id=1
jury/rejudgings.php
jury/scoreboard.php
jury/scoreboard.php?country[]=NLD
jury/show_source.php?id=1
jury/show_source.php?id=3
jury/submission.php?id=1
jury/submission.php?id=91
jury/submission.php?id=94
jury/submissions.php?view[0]
jury/submissions.php?view[1]
jury/submissions.php?view[2]
jury/team.php?id=2
jury/team.php?id=2&cmd=edit
jury/team_affiliations.php
jury/team_affiliation.php?id=1
jury/team_categories.php
jury/team_category.php?id=1
jury/teams.php
jury/testcase.php?probid=10
jury/user.php?id=1
jury/users.php
api/'
OFS="$IFS"
IFS='
'
check_html ()
{
set +e
url="$LIVEURLPREFIX$1"
TEMP="$TEMPDIR/$(echo "$1" | sed 's!/!_!g').html"
curl -s -L -g ${USER:+-u$USER:$PASS} "$url" > "$TEMP"
# Filter out some unfixable errors and normalize file/URL output:
java -jar $VNUCHECKER "$TEMP" 2>&1 | \
grep -v 'error: Attribute .*sorttable_customkey.* not allowed on element' | \
sed -e 's!^"file.*validate-[a-zA-Z0-9]*/!!' \
-e 's!^\(api\|jury\|team\|public\)_!\1/!' \
-e 's/\.html":/ /g;s/%3F/?/g;s/%26/\&/g;s/%3D/=/g;s/%5B/[/g;s/%5D/]/g'
set -e
}
for i in $URLS ; do
check_html "$i"
done
IFS="$OFS"
[ "$DEBUG" ] || rm -rf "$TEMPDIR"
exit 0