summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShaun McCance <shaunm@gnome.org>2019-04-26 12:11:13 -0400
committerShaun McCance <shaunm@gnome.org>2019-04-26 12:11:13 -0400
commitd08118955f2e29c7d263d79aff2580baaeabe576 (patch)
tree4d60707c01aeaa232d763c560c7fc0e5fe7f83e7
parentff8c59f30f31cccf344c35b70962ac4e9bccb577 (diff)
downloadyelp-tools-d08118955f2e29c7d263d79aff2580baaeabe576.tar.gz
yelp-check: Fix validation for DocBook 5 with https redirects
At some point, docbook.org starting doing 301 redirects to send all requests thru https. Unfortunately, neither jing nor xmllint likes these redirects, and xmllint doesn't do https at all. So, we have to do some special casing depending on the validator and on whether we have local copies in the catalogs. Fun stuff.
-rwxr-xr-xtools/yelp-check.in22
1 files changed, 20 insertions, 2 deletions
diff --git a/tools/yelp-check.in b/tools/yelp-check.in
index 526679d..d46e004 100755
--- a/tools/yelp-check.in
+++ b/tools/yelp-check.in
@@ -1060,11 +1060,29 @@ yelp_validate_db () {
major=$(echo "$version" | cut -c1)
if [ "x$major" = "x5" ]; then
check_out_file=`mktemp "${TMPDIR:-/tmp}"/yelp-XXXXXXXX`
- rng_uri="http://docbook.org/xml/$version/rng/docbook.rng"
+ # Canonical URIs are http, but they 301 redirect to https. jing can handle
+ # https fine, but not the redirect. And jing doesn't look at catalogs. So
+ # just always feed jing an https URI.
if [ "x$check_jing" = "x1" ]; then
+ rng_uri="https://docbook.org/xml/$version/rng/docbook.rng"
jing -i "$rng_uri" "$1" > "$check_out_file" 2>&1
else
- xmllint --noout --xinclude --noent --relaxng "$rng_uri" "$1" > "$check_out_file" 2>&1
+ # xmllint, on the other hand, does support catalogs. It also doesn't
+ # do the redirect, but it wouldn't matter if it did because it doesn't
+ # do https. So if the schema is available locally in the catalog, hand
+ # xmllint the http URI so it can use the local copy. Otherwise, we have
+ # to get curl involved to do https.
+ rng_uri="http://docbook.org/xml/$version/rng/docbook.rng"
+ incat=$(xmlcatalog /etc/xml/catalog "$rng_uri" | grep -c '^file:')
+ if [ "x$incat" != "x0" ]; then
+ xmllint --noout --xinclude --noent --relaxng "$rng_uri" "$1" > "$check_out_file" 2>&1
+ else
+ rng_uri="https://docbook.org/xml/$version/rng/docbook.rng"
+ check_rng_file=`mktemp "${TMPDIR:-/tmp}"/yelp-XXXXXXXX`
+ curl -sL -o "$check_rng_file" "$rng_uri"
+ xmllint --noout --xinclude --noent --relaxng "$check_rng_file" "$1" > "$check_out_file" 2>&1
+ rm "$check_rng_file"
+ fi
fi
yelp_check_retval="$?"
cat "$check_out_file" | grep -v 'validates$'