jenkins-bot has submitted this change and it was merged.
Change subject: Fix newline in three or more nested templates
......................................................................
Fix newline in three or more nested templates
NESTED_TEMPLATE_REGEX uses .* without re.DOTALL,
so it fails to go into unhandled_depth mode when
a newline appears in the nested templates.
Bug: T140608
Change-Id: I91c27b657541abb5ebee061b0df34d4882d6f70a
---
M pywikibot/textlib.py
M tests/textlib_tests.py
2 files changed, 11 insertions(+), 1 deletion(-)
Approvals:
Mpaa: Looks good to me, approved
Xqt: Looks good to me, but someone else must approve
jenkins-bot: Verified
diff --git a/pywikibot/textlib.py b/pywikibot/textlib.py
index 32f8fe9..d379203 100644
--- a/pywikibot/textlib.py
+++ b/pywikibot/textlib.py
@@ -99,7 +99,7 @@
}}
|
(?P<unhandled_depth>{{\s*[^{\|#0-9][^{\|#]*?\s* [^{]* {{ .* }})
-""", re.VERBOSE)
+""", re.VERBOSE | re.DOTALL)
# The following regex supports wikilinks anywhere after the first pipe
# and correctly matches the end of the file link if the wikilink contains
diff --git a/tests/textlib_tests.py b/tests/textlib_tests.py
index 89093ac..103d848 100644
--- a/tests/textlib_tests.py
+++ b/tests/textlib_tests.py
@@ -637,6 +637,16 @@
self.assertIsNotNone(m.group('unhandled_depth'))
self.assertTrue(m.group(0).endswith('foo {{bar}}'))
+ m = func('{{a|\n{{c|{{d|}} }}\n| foo = bar }} foo {{bar}} baz')
+ self.assertIsNotNone(m)
+ self.assertIsNotNone(m.group(0))
+ self.assertIsNone(m.group('name'))
+ self.assertIsNone(m.group(1))
+ self.assertIsNone(m.group('params'))
+ self.assertIsNone(m.group(2))
+ self.assertIsNotNone(m.group('unhandled_depth'))
+ self.assertTrue(m.group(0).endswith('foo {{bar}}'))
+
class TestGenericTemplateParams(PatchingTestCase):
--
To view, visit
https://gerrit.wikimedia.org/r/299541
To unsubscribe, visit
https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I91c27b657541abb5ebee061b0df34d4882d6f70a
Gerrit-PatchSet: 2
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Mpaa <mpaa.wiki(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot <>