Meno25 has submitted this change. ( 
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1275355?usp=email )

Change subject: [bugfix] Ignote UnicodeDecodeError in 
cosmetic_changes.cleanUpLinks
......................................................................

[bugfix] Ignote UnicodeDecodeError in cosmetic_changes.cleanUpLinks

Bug: T423062
Change-Id: I5a4070a4f0c72190e0af153352bd10db137a73d7
Signed-off-by: Xqt <[email protected]>
---
M pywikibot/cosmetic_changes.py
1 file changed, 7 insertions(+), 2 deletions(-)

Approvals:
  Meno25: Verified; Looks good to me, approved




diff --git a/pywikibot/cosmetic_changes.py b/pywikibot/cosmetic_changes.py
index ef59ad7..2751377 100644
--- a/pywikibot/cosmetic_changes.py
+++ b/pywikibot/cosmetic_changes.py
@@ -557,8 +557,13 @@
         # unmodified, or returns a replacement.
         def handleOneLink(match: re.Match[str]) -> str:
             # Convert URL-encoded characters to str
-            titleWithSection = url2string(match['titleWithSection'],
-                                          encodings=self.site.encodings())
+            try:
+                titleWithSection = url2string(match['titleWithSection'],
+                                              encodings=self.site.encodings())
+            except UnicodeDecodeError:
+                # Ignore broken links
+                return match.group()
+
             label = match['label']
             trailingChars = match['linktrail']
             newline = match['newline'] or ''

--
To view, visit 
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1275355?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.wikimedia.org/r/settings?usp=email

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

Reply via email to