|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
dmitryg Smarty Rookie
Joined: 06 Nov 2013 Posts: 5
|
Posted: Wed Nov 06, 2013 11:17 pm Post subject: Smarty 2 compile_tag regular expression problem |
|
|
I was asked to check a website which uses Smarty 2. Website dies without giving error.
I tracked the problem to the first preg_match call at Smarty Compiler _compile_tag function. This preg_match call just dies. Doesn't throw error in log or anything.
The website was using very old version of Smarty, version 2.6.12 . I updated today to 2.6.28 released in October 2013. The same error persists.
The website had been working fine for years.
The problem seems to happen for any tag trying to be compiled. For example a very simple one like include file="template_file_name.tpl" .
I inserted a mail() function call to send myself the generated regular expression. It is huge, about 10,000 characters long. I pasted it in a variable in a test script, and used it in a preg_match call in that test script where there is nothing else. Just the hardcoded regex and preg_match call. In this case I get a warning in error_log:
PHP Warning: preg_match() [<a href='function.preg-match'>function.preg-match</a>]: Compilation failed: nothing to repeat at offset 42 .
Can anyone help with this? Any help will be greatly appreciated.
Thanks. |
|
Back to top |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
Posted: Thu Nov 07, 2013 12:48 am Post subject: |
|
|
The PHP pcre.backtrack_limit may be too low for such huge regular expression.
Call ini_set('pcre.backtrack_limit', -1); in the script to switch off any limit. |
|
Back to top |
|
dmitryg Smarty Rookie
Joined: 06 Nov 2013 Posts: 5
|
Posted: Thu Nov 07, 2013 2:06 am Post subject: |
|
|
Thank you U.Tews.
Looks like this helped. Most pages of website work now. Some pages still die with no error, so I need to check those. It is puzzling that I don't see any error. It's as if the Apache process died for some reason, and no error is logged in error_log.
I made the change you mentioned, and also set pcre.recursion_limit to 300000 (backtrack and recursion were both set to 100000, when I changed backtrack to -1 as you suggested things started working. With recursion I am not sure to use -1, I increased limit)
Thanks again.
U.Tews wrote: | The PHP pcre.backtrack_limit may be too low for such huge regular expression.
Call ini_set('pcre.backtrack_limit', -1); in the script to switch off any limit. |
|
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|