Skip to content

Commit

Permalink
- bugfix output filter trimwhitespace could run into the pcre.backtra…
Browse files Browse the repository at this point in the history
…ck_limit on large output (code.google issue 220)
  • Loading branch information
uwetews committed May 20, 2015
1 parent 5468f14 commit b8eb878
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions change_log.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
 ===== 3.1.24.dev ===== (xx.xx.2015)
19.05.2015
- bugfix compiler did overwrite existing variable value when setting the nocache attribute https://github.com/smarty-php/smarty/issues/39
- bugfix output filter trimwhitespace could run into the pcre.backtrack_limit on large output (code.google issue 220)

18.05.2015
- improvement introduce shortcuts in lexer/parser rules for most frequent terms for higher
Expand Down
4 changes: 2 additions & 2 deletions libs/plugins/outputfilter.trimwhitespace.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ function smarty_outputfilter_trimwhitespace($source)

// capture html elements not to be messed with
$_offset = 0;
if (preg_match_all('#<(script|pre|textarea)[^>]*>.*?</\\1>#is', $source, $matches, PREG_OFFSET_CAPTURE | PREG_SET_ORDER)) {
if (preg_match_all('#(<script[^>]*>.*?</script[^>]*>)|(<textarea[^>]*>.*?</textarea[^>]*>)|(<pre[^>]*>.*?</pre[^>]*>)#is', $source, $matches, PREG_OFFSET_CAPTURE | PREG_SET_ORDER)) {
foreach ($matches as $match) {
$store[] = $match[0][0];
$_length = strlen($match[0][0]);
Expand All @@ -62,7 +62,7 @@ function smarty_outputfilter_trimwhitespace($source)
// can't remove them entirely, becaue that might break poorly implemented CSS display:inline-block elements
'#(:SMARTY@!@|>)\s+(?=@!@SMARTY:|<)#s' => '\1 \2',
// remove spaces between attributes (but not in attribute values!)
'#(([a-z0-9]\s*=\s*(["\'])[^\3]*?\3)|<[a-z0-9_]+)\s+([a-z/>])#is' => '\1 \4',
'#(([a-z0-9]\s*=\s*("[^"]*?")|(\'[^\']*?\'))|<[a-z0-9_]+)\s+([a-z/>])#is' => '\1 \5',
// note: for some very weird reason trim() seems to remove spaces inside attributes.
// maybe a \0 byte or something is interfering?
'#^\s+<#Ss' => '<',
Expand Down

0 comments on commit b8eb878

Please sign in to comment.