fix order of replacements (mohrt)

This commit is contained in:
monte.ohrt
2013-07-02 14:11:12 +00:00
parent 739688a454
commit a0f26a96cc

View File

@@ -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;