jenkins-bot has submitted this change. ( 
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1225150?usp=email )

Change subject: FIX: Remove invisible chars from Section.heading
......................................................................

FIX: Remove invisible chars from Section.heading

Section.heading is used to validate whether a Page.section() exists.
This may fail if the section contains invisible chars like LTR or RTL
but the MediaWiki link works. This patch removes invisible chars from
Section.heading but keeps Section title unchanged.

Bug: T411307
Change-Id: Ide04ca1b1b4eac05ae4ae7211db8496e5200f87a
---
M pywikibot/textlib.py
1 file changed, 5 insertions(+), 1 deletion(-)

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




diff --git a/pywikibot/textlib.py b/pywikibot/textlib.py
index 942cef3..5e08c36 100644
--- a/pywikibot/textlib.py
+++ b/pywikibot/textlib.py
@@ -22,6 +22,7 @@
 from pywikibot.family import Family
 from pywikibot.time import TZoneFixedOffset
 from pywikibot.tools import ModuleDeprecationWrapper, first_lower, first_upper
+from pywikibot.tools.chars import INVISIBLE_REGEX
 from pywikibot.userinterfaces.transliteration import NON_ASCII_DIGITS


@@ -1112,9 +1113,12 @@
         """Return the section title without equal signs.

         .. versionadded:: 8.2
+        .. versionchanged:: 11.0
+           Invisible chars like LTR or RTO are removed.
         """
         level = self.level
-        return self.title[level:-level].strip()
+        title = self.title[level:-level].strip()
+        return INVISIBLE_REGEX.sub('', title)


 class SectionList(list):

--
To view, visit 
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1225150?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: Ide04ca1b1b4eac05ae4ae7211db8496e5200f87a
Gerrit-Change-Number: 1225150
Gerrit-PatchSet: 3
Gerrit-Owner: Xqt <[email protected]>
Gerrit-Reviewer: JJMC89 <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
Pywikibot-commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to