jenkins-bot has submitted this change and it was merged.
Change subject: [bugfix] Check for invalid references tags ......................................................................
[bugfix] Check for invalid references tags
bug: T98115 Change-Id: I2fe3858fe036a0179c29c6746e1b10fa062cc00c --- M scripts/noreferences.py 1 file changed, 16 insertions(+), 2 deletions(-)
Approvals: Ladsgroup: Looks good to me, approved jenkins-bot: Verified
diff --git a/scripts/noreferences.py b/scripts/noreferences.py index 24f3669..1c22bbb 100755 --- a/scripts/noreferences.py +++ b/scripts/noreferences.py @@ -34,7 +34,7 @@ a list of affected articles """ # -# (C) Pywikibot team, 2007-2014 +# (C) Pywikibot team, 2007-2015 # # Distributed under the terms of the MIT license. # @@ -534,6 +534,20 @@ * Returns : The modified pagetext
""" + # Do we have a malformed <reference> tag which could be repaired? + + # Repair two opening tags or a opening and an empty tag + pattern = re.compile(r'< *references *>(.*?)' + r'< */?\s*references */? *>', re.DOTALL) + if pattern.search(oldText): + pywikibot.output('Repairing references tag') + return re.sub(pattern, '<references>\1</references>', oldText) + # Repair single unclosed references tag + pattern = re.compile(r'< *references *>') + if pattern.search(oldText): + pywikibot.output('Repairing references tag') + return re.sub(pattern, '<references />', oldText) + # Is there an existing section where we can add the references tag? for section in i18n.translate(self.site, referencesSections): sectionR = re.compile(r'\r?\n=+ *%s *=+ *\r?\n' % section) @@ -548,7 +562,7 @@ index = match.end() else: pywikibot.output( - u'Adding references tag to existing %s section...\n' + 'Adding references tag to existing %s section...\n' % section) newText = ( oldText[:match.end()] + u'\n' +
pywikibot-commits@lists.wikimedia.org