From 3e0b1f7cf6b3f5d085f123ffb5b68f005ec33d1f Mon Sep 17 00:00:00 2001
From: Kunal Mehta
Date: Sat, 26 May 2018 22:57:55 -0700
Subject: [PATCH] Improve Parser::braceSubstitution() coverage
Change-Id: I3d9426143fe486c6aed0494b68773a36e24c02d9
---
tests/parser/ParserTestRunner.php | 12 ++++++++
tests/parser/parserTests.txt | 47 +++++++++++++++++++++++++++++++
2 files changed, 59 insertions(+)
diff --git a/tests/parser/ParserTestRunner.php b/tests/parser/ParserTestRunner.php
index 08ec9f6d8d..ce1dae60ad 100644
--- a/tests/parser/ParserTestRunner.php
+++ b/tests/parser/ParserTestRunner.php
@@ -829,6 +829,13 @@ class ParserTestRunner {
$titleText = 'Parser test';
}
+ if ( isset( $opts['maxincludesize'] ) ) {
+ $options->setMaxIncludeSize( $opts['maxincludesize'] );
+ }
+ if ( isset( $opts['maxtemplatedepth'] ) ) {
+ $options->setMaxTemplateDepth( $opts['maxtemplatedepth'] );
+ }
+
$local = isset( $opts['local'] );
$preprocessor = isset( $opts['preprocessor'] ) ? $opts['preprocessor'] : null;
$parser = $this->getParser( $preprocessor );
@@ -1083,6 +1090,11 @@ class ParserTestRunner {
'wgFragmentMode' => [ 'legacy' ],
];
+ $nonIncludable = self::getOptionValue( 'wgNonincludableNamespaces', $opts, false );
+ if ( $nonIncludable !== false ) {
+ $setup['wgNonincludableNamespaces'] = [ $nonIncludable ];
+ }
+
if ( $config ) {
$configLines = explode( "\n", $config );
diff --git a/tests/parser/parserTests.txt b/tests/parser/parserTests.txt
index d17fbbe31a..bffc56ed11 100644
--- a/tests/parser/parserTests.txt
+++ b/tests/parser/parserTests.txt
@@ -109,6 +109,14 @@ Template:echo
{{{1}}}
!! endarticle
+!! article
+Template:echo3
+!! text
+{{{1}}}
+{{{1}}}
+{{{1}}}
+!! endarticle
+
// For Serbian; localize Template namespace
!! article
Шаблон:Echo
@@ -128,6 +136,12 @@ Template:echo_with_div
{{{1}}}
!! endarticle
+!! article
+Template:echo with depth
+!! text
+{{echo|{{{1}}}}}
+!! endarticle
+
!! article
Template:blank_param
!! text
@@ -1825,6 +1839,28 @@ b
!! end
+!! test
+post-expand include size being exceeded
+!! options
+maxincludesize=20
+!! wikitext
+{{echo3|1234567890}}
+!! html
+Template:Echo3
+
+!! end
+
+!! test
+max template depth being reached
+!! options
+maxtemplatedepth=1
+!! wikitext
+{{echo with depth|too deep!}}
+!! html
+Template recursion depth limit exceeded (1)
+
+!! end
+
!! test
Multiple comments should still parse as SOL-transparent
!! options
@@ -11504,6 +11540,17 @@ Template from main namespace
!! end
+!! test
+Template from non-includable namespace
+!! options
+wgNonincludableNamespaces=10
+!! wikitext
+{{echo|uh oh!}}
+!! html
+Template:Echo
+
+!! end
+
!! article
Template:table
!! text
--
2.20.1