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

Change subject: [bugfix] Avoid HTML entity substitution in <syntaxhighlight>
......................................................................

[bugfix] Avoid HTML entity substitution in <syntaxhighlight>

Bug: T254350
Change-Id: I70db180f6755e8b92675500e35969dc6f205800a
---
M pywikibot/cosmetic_changes.py
M tests/cosmetic_changes_tests.py
2 files changed, 10 insertions(+), 3 deletions(-)

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



diff --git a/pywikibot/cosmetic_changes.py b/pywikibot/cosmetic_changes.py
index 1baba11..e8dc359 100755
--- a/pywikibot/cosmetic_changes.py
+++ b/pywikibot/cosmetic_changes.py
@@ -646,7 +646,10 @@
         if self.template:
             ignore += [32]  # Space ( )
             ignore += [58]  # Colon (:)
-        text = pywikibot.html2unicode(text, ignore=ignore, exceptions=['code'])
+        # TODO: T254350 - what other extension tags should be avoided?
+        # (graph, math, score, timeline, etc.)
+        text = pywikibot.html2unicode(
+            text, ignore=ignore, exceptions=['comment', 'source'])
         return text

     def removeEmptySections(self, text):
diff --git a/tests/cosmetic_changes_tests.py b/tests/cosmetic_changes_tests.py
index bf56944..07bb02e 100644
--- a/tests/cosmetic_changes_tests.py
+++ b/tests/cosmetic_changes_tests.py
@@ -63,8 +63,12 @@
             self.cct.resolveHtmlEntities(
                 '&amp;#&nbsp;#&#32;#&#48;#&#62;#&#120;'))
         self.assertEqual(
-            '<code>&#32;</code>',
-            self.cct.resolveHtmlEntities('<code>&#32;</code>'))
+            '<syntaxhighlight>&#32;</syntaxhighlight>',
+            self.cct.resolveHtmlEntities(
+                '<syntaxhighlight>&#32;</syntaxhighlight>'))
+        self.assertEqual(
+            '<!-- &ndash; -->',
+            self.cct.resolveHtmlEntities('<!-- &ndash; -->'))

     def test_removeUselessSpaces(self):
         """Test removeUselessSpaces method."""

--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/609297
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: I70db180f6755e8b92675500e35969dc6f205800a
Gerrit-Change-Number: 609297
Gerrit-PatchSet: 6
Gerrit-Owner: Matěj Suchánek <[email protected]>
Gerrit-Reviewer: Dvorapa <[email protected]>
Gerrit-Reviewer: Matěj Suchánek <[email protected]>
Gerrit-Reviewer: Xqt <[email protected]>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged
_______________________________________________
Pywikibot-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/pywikibot-commits

Reply via email to