jenkins-bot submitted this change.
[fix] Skip invalid link titles in fixing_redirects.py
- If a title contains a replacement character ignore this link from processing
- Raise a more informative exception if replacement char was found in title.
Bug: T324434
Change-Id: I3c802a5790ef6239342b5f2e01a3c5cfa6d2d21d
---
M pywikibot/page/_links.py
M scripts/fixing_redirects.py
2 files changed, 18 insertions(+), 2 deletions(-)
diff --git a/pywikibot/page/_links.py b/pywikibot/page/_links.py
index 1dd4e3f..36ba716 100644
--- a/pywikibot/page/_links.py
+++ b/pywikibot/page/_links.py
@@ -314,7 +314,7 @@
# This code was adapted from Title.php : secureAndSplit()
if '\ufffd' in t:
raise InvalidTitleError(
- '{!r} contains illegal char {!r}'.format(t, '\ufffd'))
+ fr'{t!r} contains illegal replacement char \ufffd')
# Cleanup whitespace
sep = self._source.family.title_delimiter_and_aliases[0]
diff --git a/scripts/fixing_redirects.py b/scripts/fixing_redirects.py
index 98cbc59..defde99 100755
--- a/scripts/fixing_redirects.py
+++ b/scripts/fixing_redirects.py
@@ -84,7 +84,10 @@
# Make sure that next time around we will not find this same hit.
curpos = m.start() + 1
- is_interwikilink = mysite.isInterwikiLink(m['title'])
+ try:
+ is_interwikilink = mysite.isInterwikiLink(m['title'])
+ except InvalidTitleError:
+ continue # skip invalid title
# ignore interwiki links, links in the disabled area
# and links to sections of the same page
To view, visit change 871893. To unsubscribe, or for help writing mail filters, visit settings.