From ad71cb4e436a04cb46435d97b4898e5598ff46b3 Mon Sep 17 00:00:00 2001 From: Chris Mayo Date: Fri, 14 Aug 2020 19:25:21 +0100 Subject: [PATCH] Fix CssSyntaxCheck list index out of range Errors do not report the column. --- linkcheck/plugins/syntaxchecks.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/linkcheck/plugins/syntaxchecks.py b/linkcheck/plugins/syntaxchecks.py index af0e9f64..a011d6a1 100644 --- a/linkcheck/plugins/syntaxchecks.py +++ b/linkcheck/plugins/syntaxchecks.py @@ -127,15 +127,21 @@ def check_w3_errors(url_data, xml, w3type): w3type is either "W3C HTML" or "W3C CSS".""" dom = parseString(xml) for error in dom.getElementsByTagName('m:error'): - warnmsg = _( - "%(w3type)s validation error at line %(line)s col %(column)s: %(msg)s" - ) + if w3type == "W3C HTML": + warnmsg = _( + "%(w3type)s validation error at line %(line)s col %(column)s: %(msg)s" + ) + else: + warnmsg = _( + "%(w3type)s validation error at line %(line)s: %(msg)s" + ) attrs = { "w3type": w3type, "line": getXmlText(error, "m:line"), - "column": getXmlText(error, "m:col"), "msg": getXmlText(error, "m:message"), } + if w3type == "W3C HTML": + attrs["column"] = getXmlText(error, "m:col") url_data.add_warning(warnmsg % attrs)