Xqt has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/401490 )

Change subject: [bugfix] Don't allow interwiki prefix when adding categories
......................................................................

[bugfix] Don't allow interwiki prefix when adding categories

Bug: T183908
Change-Id: I4ac7aa9aef2a98f93daa9ddb77fe2eedfc2b9521
---
M pywikibot/textlib.py
1 file changed, 10 insertions(+), 13 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/pywikibot/core 
refs/changes/90/401490/1

diff --git a/pywikibot/textlib.py b/pywikibot/textlib.py
index 71abed2..41595ca 100644
--- a/pywikibot/textlib.py
+++ b/pywikibot/textlib.py
@@ -7,7 +7,7 @@
 
 """
 #
-# (C) Pywikibot team, 2008-2017
+# (C) Pywikibot team, 2008-2018
 #
 # Distributed under the terms of the MIT license.
 #
@@ -1196,29 +1196,26 @@
     categoryRN = re.compile(
         r'^[^\S\n]*\[\[\s*(%s)\s*:\s*%s\s*((?:\|[^]]+)?\]\])[^\S\n]*\n'
         % (catNamespace, title), re.I | re.M)
+    exceptions = ['nowiki', 'comment', 'math', 'pre', 'source']
     if newcat is None:
         # First go through and try the more restrictive regex that removes
         # an entire line, if the category is the only thing on that line (this
         # prevents blank lines left over in category lists following a 
removal.)
         text = replaceExcept(oldtext, categoryRN, '',
-                             ['nowiki', 'comment', 'math', 'pre', 'source'],
-                             site=site)
+                             exceptions, site=site)
         text = replaceExcept(text, categoryR, '',
-                             ['nowiki', 'comment', 'math', 'pre', 'source'],
-                             site=site)
+                             exceptions, site=site)
     elif add_only:
-        text = replaceExcept(oldtext, categoryR,
-                             '{0}\n{1}'.format(
-                                 oldcat.title(asLink=True),
-                                 newcat.title(asLink=True)),
-                             ['nowiki', 'comment', 'math', 'pre', 'source'],
-                             site=site)
+        text = replaceExcept(
+            oldtext, categoryR,
+            '{0}\n{1}'.format(oldcat.title(asLink=True, allowInterwiki=False),
+                              newcat.title(asLink=True, allowInterwiki=False)),
+            exceptions, site=site)
     else:
         text = replaceExcept(oldtext, categoryR,
                              '[[%s:%s\\2' % (site.namespace(14),
                                              
newcat.title(withNamespace=False)),
-                             ['nowiki', 'comment', 'math', 'pre', 'source'],
-                             site=site)
+                             exceptions, site=site)
     return text
 
 

-- 
To view, visit https://gerrit.wikimedia.org/r/401490
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I4ac7aa9aef2a98f93daa9ddb77fe2eedfc2b9521
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Xqt <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to