John Vandenberg has uploaded a new change for review.
https://gerrit.wikimedia.org/r/299541
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.
Change-Id: I91c27b657541abb5ebee061b0df34d4882d6f70a
---
M pywikibot/textlib.py
M tests/textlib_tests.py
2 files changed, 11 insertions(+), 1 deletion(-)
git pull ssh://gerrit.wikimedia.org:29418/pywikibot/core
refs/changes/41/299541/1
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: newchange
Gerrit-Change-Id: I91c27b657541abb5ebee061b0df34d4882d6f70a
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: John Vandenberg <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits