aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/phpbb
diff options
context:
space:
mode:
authorAndreas Fischer <bantu@phpbb.com>2013-07-22 03:07:38 +0200
committerAndreas Fischer <bantu@phpbb.com>2013-07-22 03:07:38 +0200
commit8efca016fad58e122f15e8eb2eaa1ea5aad6f809 (patch)
tree4b03f29113538c2fb2a60d3aedd051c7ecb13349 /phpBB/phpbb
parentfb5c8957ec4d5adff116dbee0bbdad7b3032b71c (diff)
parent375976eb38882f42155f1f7fa2c849add8dbcf08 (diff)
downloadforums-8efca016fad58e122f15e8eb2eaa1ea5aad6f809.tar
forums-8efca016fad58e122f15e8eb2eaa1ea5aad6f809.tar.gz
forums-8efca016fad58e122f15e8eb2eaa1ea5aad6f809.tar.bz2
forums-8efca016fad58e122f15e8eb2eaa1ea5aad6f809.tar.xz
forums-8efca016fad58e122f15e8eb2eaa1ea5aad6f809.zip
Merge remote-tracking branch 'EXreaction/ticket/11707' into develop
* EXreaction/ticket/11707: [ticket/11707] Twig DEFINE not working as expected
Diffstat (limited to 'phpBB/phpbb')
-rw-r--r--phpBB/phpbb/template/twig/lexer.php12
1 files changed, 8 insertions, 4 deletions
diff --git a/phpBB/phpbb/template/twig/lexer.php b/phpBB/phpbb/template/twig/lexer.php
index 46412ad048..1fa4c5b3e6 100644
--- a/phpBB/phpbb/template/twig/lexer.php
+++ b/phpBB/phpbb/template/twig/lexer.php
@@ -126,10 +126,14 @@ class phpbb_template_twig_lexer extends Twig_Lexer
{
$callback = function($matches)
{
- // Remove any quotes that may have been used in different implementations
- // E.g. DEFINE $TEST = 'blah' vs INCLUDE foo
- // Replace {} with start/end to parse variables (' ~ TEST ~ '.html)
- $matches[2] = str_replace(array('"', "'", '{', '}'), array('', '', "' ~ ", " ~ '"), $matches[2]);
+ // Remove matching quotes at the beginning/end if a statement;
+ // E.g. 'asdf'"' -> asdf'"
+ // E.g. "asdf'"" -> asdf'"
+ // E.g. 'asdf'" -> 'asdf'"
+ $matches[2] = preg_replace('#^([\'"])?(.+?)\1$#', '$2', $matches[2]);
+
+ // Replace template variables with start/end to parse variables (' ~ TEST ~ '.html)
+ $matches[2] = preg_replace('#{([a-zA-Z0-9_\.$]+)}#', "'~ \$1 ~'", $matches[2]);
// Surround the matches in single quotes ('' ~ TEST ~ '.html')
return "<!-- {$matches[1]} '{$matches[2]}' -->";