jenkins-bot has submitted this change and it was merged. (
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(-)
Approvals:
John Vandenberg: Looks good to me, approved
jenkins-bot: Verified
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: merged
Gerrit-Change-Id: I4ac7aa9aef2a98f93daa9ddb77fe2eedfc2b9521
Gerrit-PatchSet: 2
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Dalba <dalba.wiki(a)gmail.com>
Gerrit-Reviewer: Framawiki <framawiki(a)tools.wmflabs.org>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Zoranzoki21 <zorandori4444(a)gmail.com>
Gerrit-Reviewer: jenkins-bot <>