jenkins-bot has submitted this change and it was merged.
Change subject: [FIX] Weblinkchecker: Report malformed URLs (port) ......................................................................
[FIX] Weblinkchecker: Report malformed URLs (port)
Don't throw URL exception in the checker thread if the URL cannot be parsed.
Introduce NotAnURLError exception to allow information about malformed URLs to be passed to the reporting facility.
This is ported from 405b73862c2859f816dcfe0313c46bde760f82f3 in compat.
Bug: T76294 Change-Id: I0474ddad3b19faed598cf14c647e3c62e9270f50 --- M scripts/weblinkchecker.py 1 file changed, 13 insertions(+), 0 deletions(-)
Approvals: John Vandenberg: Looks good to me, approved jenkins-bot: Verified
diff --git a/scripts/weblinkchecker.py b/scripts/weblinkchecker.py index 5c2a0e9..2f86623 100644 --- a/scripts/weblinkchecker.py +++ b/scripts/weblinkchecker.py @@ -232,6 +232,11 @@ __next__ = next
+class NotAnURLError(BaseException): + + """The link is not an URL.""" + + class LinkChecker(object):
""" @@ -279,6 +284,8 @@ return httplib.HTTPConnection(self.host) elif self.scheme == 'https': return httplib.HTTPSConnection(self.host) + else: + raise NotAnURLError(self.url)
def getEncodingUsedByServer(self): if not self.serverEncoding: @@ -512,6 +519,12 @@ linkChecker = LinkChecker(self.url, HTTPignore=self.HTTPignore) try: ok, message = linkChecker.check() + except NotAnURLError: + ok = False + message = i18n.twtranslate(pywikibot.page.site(), + 'weblinkchecker-badurl_msg', + {'URL': self.url}) + except: pywikibot.output('Exception while processing URL %s in page %s' % (self.url, self.page.title()))
pywikibot-commits@lists.wikimedia.org