From 0dbddc795ace088a0fe93ebe8fd4520271bd131a Mon Sep 17 00:00:00 2001 From: Daniel Kraus Date: Thu, 24 Aug 2017 19:10:29 +0200 Subject: [PATCH] Use recursive regex to deal with nested braces. - Fix: Properly handle templates that include other templates. Addresses #29. --- includes/LinkTitles_Extension.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/includes/LinkTitles_Extension.php b/includes/LinkTitles_Extension.php index ea02bad..31e4c72 100644 --- a/includes/LinkTitles_Extension.php +++ b/includes/LinkTitles_Extension.php @@ -464,7 +464,9 @@ class Extension { if ( $wgLinkTitlesSkipTemplates ) { - $templatesDelimiter = '{{[^}]+}}|'; + // Use recursive regex to balance curly braces; + // see http://www.regular-expressions.info/recurse.html + $templatesDelimiter = '{{(?>[^{}]|(?R))*}}|'; } else { // Match template names (ignoring any piped [[]] links in them) // along with the trailing pipe and parameter name or closing