Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

Bug in smarty_internal_compile_include.php >=Smarty 3.1.8

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Bugs
View previous topic :: View next topic  
Author Message
jboffel
Smarty n00b


Joined: 06 Oct 2013
Posts: 1

PostPosted: Sun Oct 06, 2013 11:12 pm    Post subject: Bug in smarty_internal_compile_include.php >=Smarty 3.1.8 Reply with quote

Hi,

I'd like to report what I think is a bug in smarty_internal_compile_include.php.

if you reproduce a structure like this :

* ./smartybug.tpl {include ./static.tpl},{include ./test/test.tpl}
* ./static.tpl {1}
* ./test/test.tpl {include ./static.tpl}
* ./test/static.tpl {2}

When you render it :
Before fix it will show : 11
After fix : 12

Basically, I'd say in some configuration, include function of smarty working in relative path will fail to make a unique identifier for each template file because it will use only the relative ressource file as an identifier for the function list of subtemplates in the merged file.

I made a patch that seems to work. However, there are probably better approach to fix it. I give it here whatever to give a guess on how to solve the problem. I just make sure we only work in full path.



Before
Code:

        $include_file = $_attr['file'];
               
        if (isset($_attr['assign'])) {
            // output will be stored in a smarty variable instead of beind displayed
            $_assign = $_attr['assign'];
        }


After
Code:

        $include_file = $_attr['file'];
        if ($include_file[1] == '.') {
            $include_file = '"' . str_replace('\\', '\\\\', realpath(dirname($compiler->smarty->_current_file) . '/' . trim($include_file, '"'))) . '"';
        }
                   
        if (isset($_attr['assign'])) {
            // output will be stored in a smarty variable instead of beind displayed
            $_assign = $_attr['assign'];
        }


The str_replace is just protecting \ for windows path.
Back to top
View user's profile Send private message
U.Tews
Administrator


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

PostPosted: Sun Oct 13, 2013 5:55 pm    Post subject: Reply with quote

The fix is now in the SVN trunk and will later be included in 3.1.16

NOTE: If you use ambiguous relative file name you must also set
$smarty->allow_ambiguous_resources = true;

For some reason this flag is not in documentation. I will add it ASAP
Back to top
View user's profile Send private message
KarenAnderson
Smarty n00b


Joined: 15 Nov 2013
Posts: 1

PostPosted: Fri Nov 15, 2013 7:04 am    Post subject: Reply with quote

Hey hi..
I am finding some difficulties in detecting bugs...can I use Apache Tomcat or
Google apps email signature code..
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Bugs 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