Smarty Forum Index Smarty
The discussions here are for Smarty, a template engine for the PHP programming language.
prefilter and {extends} problem with 3.1.12

 
Post new topic   Reply to topic    Smarty Forum Index -> Plugins
View previous topic :: View next topic  
Author Message
lxs
Smarty n00b


Joined: 12 Nov 2010
Posts: 4

PostPosted: Tue Jan 08, 2013 10:20 pm    Post subject: prefilter and {extends} problem with 3.1.12 Reply with quote

Hi,

I am trying to upgrade from Smarty 3.0.7 to 3.1.12. I have a prefilter which rewrites the file argument to {extends}. With 3.1.12 I now get an "unmatched {block} {/block} pairs" when rendering my templates with {extends} tags in them.

As far as I can tell the reason this is happening is because while the prefiltered content is correctly passed to the lexer and parser, Smarty_Internal_Compile_Extends does a bunch of checks against the original template content. As a result the following code in smarty_internal_compile_extends.php does not behave correctly:

Code:
$_content = ($this->mbstring_overload ? mb_substr($compiler->template->source->content, $compiler->lex->counter - 1, 20000000, 'latin1') : substr($compiler->template->source->content, $compiler->lex->counter - 1));


Specifically $compiler->template->source->content is the original text of the template file (before prefilter) and $compiler->lex->counter is the offset into the prefiltered text just after the {extends} tag. Because my filter has made changed the length of the {extends} tag, the lexer offset isn't correct for the original (before prefilter) content. Because my prefilter happens to make the {extends} tag longer, the substr() ends up removing the first {block} tag and causes the "unmatched {block} {/block} pairs" error.


I will attempt to see if I can come up with another way to get the behavior I want which does not use prefilters, however I thought I should mention this issue.

--lxs
Back to top
View user's profile Send private message
U.Tews
Administrator


Joined: 22 Nov 2006
Posts: 4703
Location: Hamburg / Germany

PostPosted: Wed Jan 09, 2013 12:08 am    Post subject: Reply with quote

The bugfix is now in the SVN trunk and will later be included in the 3.1.13 release
Back to top
View user's profile Send private message
lxs
Smarty n00b


Joined: 12 Nov 2010
Posts: 4

PostPosted: Wed Jan 09, 2013 12:11 am    Post subject: Reply with quote

Good to know!

Thanks for the quick response,

--lxs
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Smarty Forum Index -> Plugins All times are GMT
Page 1 of 1

 
Jump to:  
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
Protected by Anti-Spam ACP