mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 14:18:52 +00:00
[ticket/11816] Fix multiple parenthesis as well before $VARs in templates
PHPBB3-11816
This commit is contained in:
parent
6ba2fb6d62
commit
9152455d70
3 changed files with 8 additions and 5 deletions
|
@ -229,18 +229,18 @@ class phpbb_template_twig_lexer extends Twig_Lexer
|
||||||
{
|
{
|
||||||
$inner = $matches[2];
|
$inner = $matches[2];
|
||||||
// Replace $TEST with definition.TEST
|
// Replace $TEST with definition.TEST
|
||||||
$inner = preg_replace('#(\s\(?!?)\$([a-zA-Z_0-9]+)#', '$1definition.$2', $inner);
|
$inner = preg_replace('#(\s\(*!?)\$([a-zA-Z_0-9]+)#', '$1definition.$2', $inner);
|
||||||
|
|
||||||
// Replace .foo with loops.foo|length
|
// Replace .foo with loops.foo|length
|
||||||
$inner = preg_replace('#(\s\(?!?)\.([a-zA-Z_0-9]+)([^a-zA-Z_0-9\.])#', '$1loops.$2|length$3', $inner);
|
$inner = preg_replace('#(\s\(*!?)\.([a-zA-Z_0-9]+)([^a-zA-Z_0-9\.])#', '$1loops.$2|length$3', $inner);
|
||||||
|
|
||||||
// Replace .foo.bar with foo.bar|length
|
// Replace .foo.bar with foo.bar|length
|
||||||
$inner = preg_replace('#(\s\(?!?)\.([a-zA-Z_0-9\.]+)([^a-zA-Z_0-9\.])#', '$1$2|length$3', $inner);
|
$inner = preg_replace('#(\s\(*!?)\.([a-zA-Z_0-9\.]+)([^a-zA-Z_0-9\.])#', '$1$2|length$3', $inner);
|
||||||
|
|
||||||
return "<!-- {$matches[1]}IF{$inner}-->";
|
return "<!-- {$matches[1]}IF{$inner}-->";
|
||||||
};
|
};
|
||||||
|
|
||||||
return preg_replace_callback('#<!-- (ELSE)?IF((.*?) \(?!?[\$|\.]([^\s]+)(.*?))-->#', $callback, $code);
|
return preg_replace_callback('#<!-- (ELSE)?IF((.*?) \(*!?[\$|\.]([^\s]+)(.*?))-->#', $callback, $code);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -158,7 +158,7 @@ class phpbb_template_template_test extends phpbb_template_template_test_case
|
||||||
array(),
|
array(),
|
||||||
array('test_loop' => array(array(), array(), array(), array(), array(), array(), array()), 'test' => array(array()), 'test.deep' => array(array()), 'test.deep.defines' => array(array())),
|
array('test_loop' => array(array(), array(), array(), array(), array(), array(), array()), 'test' => array(array()), 'test.deep' => array(array()), 'test.deep.defines' => array(array())),
|
||||||
array(),
|
array(),
|
||||||
"xyz\nabc\n\$VALUE == 'abc'\n(\$VALUE == 'abc')\n!\$DOESNT_EXIST\n(!\$DOESNT_EXIST)\nabc\nbar\nbar\nabc\ntest!@#$%^&*()_-=+{}[]:;\",<.>/?[]|foobar|",
|
"xyz\nabc\n\$VALUE == 'abc'\n(\$VALUE == 'abc')\n((\$VALUE == 'abc'))\n!\$DOESNT_EXIST\n(!\$DOESNT_EXIST)\nabc\nbar\nbar\nabc\ntest!@#$%^&*()_-=+{}[]:;\",<.>/?[]|foobar|",
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'define_advanced.html',
|
'define_advanced.html',
|
||||||
|
|
|
@ -10,6 +10,9 @@ $VALUE == 'abc'
|
||||||
<!-- IF ($VALUE == 'abc') -->
|
<!-- IF ($VALUE == 'abc') -->
|
||||||
($VALUE == 'abc')
|
($VALUE == 'abc')
|
||||||
<!-- ENDIF -->
|
<!-- ENDIF -->
|
||||||
|
<!-- IF (($VALUE == 'abc')) -->
|
||||||
|
(($VALUE == 'abc'))
|
||||||
|
<!-- ENDIF -->
|
||||||
<!-- IF !$DOESNT_EXIST -->
|
<!-- IF !$DOESNT_EXIST -->
|
||||||
!$DOESNT_EXIST
|
!$DOESNT_EXIST
|
||||||
<!-- ENDIF -->
|
<!-- ENDIF -->
|
||||||
|
|
Loading…
Add table
Reference in a new issue