XZise has uploaded a new change for review.
https://gerrit.wikimedia.org/r/176509
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(-)
git pull ssh://gerrit.wikimedia.org:29418/pywikibot/core
refs/changes/09/176509/1
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()))
--
To view, visit https://gerrit.wikimedia.org/r/176509
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I0474ddad3b19faed598cf14c647e3c62e9270f50
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: XZise <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits