mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-05 10:54:27 +02:00
fix order of replacements (mohrt)
This commit is contained in:
@@ -74,13 +74,11 @@ function smarty_outputfilter_trimwhitespace($source, Smarty_Internal_Template $s
|
|||||||
// maybe a \0 byte or something is interfering?
|
// maybe a \0 byte or something is interfering?
|
||||||
// $source = trim( $source );
|
// $source = trim( $source );
|
||||||
|
|
||||||
// capture html elements not to be messed with
|
|
||||||
$_offset = 0;
|
$_offset = 0;
|
||||||
if (preg_match_all('#@!@SMARTY:([0-9]+):SMARTY@!@#is', $source, $matches, PREG_OFFSET_CAPTURE | PREG_SET_ORDER)) {
|
if (preg_match_all('#@!@SMARTY:([0-9]+):SMARTY@!@#is', $source, $matches, PREG_OFFSET_CAPTURE | PREG_SET_ORDER)) {
|
||||||
foreach ($matches as $match) {
|
foreach ($matches as $match) {
|
||||||
$store[] = $match[0][0];
|
|
||||||
$_length = strlen($match[0][0]);
|
$_length = strlen($match[0][0]);
|
||||||
$replace = array_shift($store);
|
$replace = $store[$match[1][0]];
|
||||||
$source = substr_replace($source, $replace, $match[0][1] + $_offset, $_length);
|
$source = substr_replace($source, $replace, $match[0][1] + $_offset, $_length);
|
||||||
|
|
||||||
$_offset += strlen($replace) - $_length;
|
$_offset += strlen($replace) - $_length;
|
||||||
|
Reference in New Issue
Block a user