ranlt / smarty-php

Automatically exported from code.google.com/p/smarty-php
0 stars 0 forks source link

function smarty_outputfilter_trimwhitespace() returns null for really large input #220

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Hi,

in smarty_outputfilter_trimwhitespace() filter there is a preg_replace() call 
on line 72. When the scanned text, i.e. $source's content, is really long the 
preg_replace() returns null which results into a blank page.

This is because of the usage backreferences in the pattern on line 65. On a 
really long input the pcre.backtrack_limit is exceeded (see 
http://php.net/manual/en/pcre.configuration.php) for default configuration. 
Raising this limit helps.

According to the PHP guys it's not a bug that preg_replace() returns null in 
such situations (see https://bugs.php.net/bug.php?id=63651). IMHO it is - 
preg_replace() could throw an exception. Nevertheless I think it should be 
fixed at least in Smarty. Probably by rewriting the pattern on line 65 to 
something without backreferences (add some ORs)?

Thank you for your consideration.

Original issue reported on code.google.com by wirt...@gmail.com on 6 Jan 2015 at 1:42

GoogleCodeExporter commented 9 years ago
Smarty version 3.1.21

Original comment by wirt...@gmail.com on 6 Jan 2015 at 1:44