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):