jenkins-bot has submitted this change. ( 
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/871893 )

Change subject: [fix] Skip invalid link titles in fixing_redirects.py
......................................................................

[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(-)

Approvals:
  Meno25: Looks good to me, approved
  jenkins-bot: Verified




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 https://gerrit.wikimedia.org/r/c/pywikibot/core/+/871893
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.wikimedia.org/r/settings

Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: I3c802a5790ef6239342b5f2e01a3c5cfa6d2d21d
Gerrit-Change-Number: 871893
Gerrit-PatchSet: 2
Gerrit-Owner: Xqt <[email protected]>
Gerrit-Reviewer: D3r1ck01 <[email protected]>
Gerrit-Reviewer: Meno25 <[email protected]>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged
_______________________________________________
Pywikibot-commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to