]> Pileus Git - ~andy/fetchmail/blob - t.validate-xhtml
Sign SA 2011-01/CVE-2011-1947.
[~andy/fetchmail] / t.validate-xhtml
1 #! /bin/sh
2
3 # This test script validates all *.html files as XHTML.
4
5 set -eu
6 e=0
7 fail=
8 IFS=$(printf '\n\t')
9
10 # smoke test validator for XHTML 1.0 Transitional, and skip if it fails
11 cat - <<'_EOF'  | xmllint 2>/dev/null --nonet --postvalid --noout - || exit 77
12 <?xml version="1.0" encoding="US-ASCII"?>
13 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
14 <html xmlns="http://www.w3.org/1999/xhtml">
15     <head><title /></head><body></body></html>
16 _EOF
17 # ditto for XHTML 1.1 (asciidoc generates that)
18 cat - <<'_EOF'  | xmllint 2>/dev/null --nonet --postvalid --noout - || exit 77
19 <?xml version="1.0" encoding="US-ASCII"?>
20 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
21 <html xmlns="http://www.w3.org/1999/xhtml">
22     <head><title /></head><body><p></p></body></html>
23 _EOF
24
25 for i in "${srcdir}"/*.html ; do
26     case "$i" in
27         */fetchmail-man.html) continue ;;
28 #       */Mailbox-Names-UTF7.html) continue ;;
29     esac
30     xmllint --postvalid --noout "$i" || { e=1 ; fail="$i${fail:+" "}$fail" ; }
31 done
32 if [ $e != 0 ] ; then
33     echo >&2 ">>>>> Invalid XHTML in files: ${fail}."
34 fi
35 exit $e