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

templateExists return false on 3.0.7

 
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
sskaje
Smarty Rookie


Joined: 12 Nov 2010
Posts: 9

PostPosted: Wed Feb 16, 2011 7:56 am    Post subject: templateExists return false on 3.0.7 Reply with quote

it works well on 3.0.6 but false was always returned after upgrading to 3.0.7.

and a typo:

Code:

    public function __get($property_name)
    {
       if ($property_name == 'resource_object') {
          // load template resource
          $this->resource_object = null;
           if (!$this->parseResourceName ($this->template_resource, $this->resource_type, $this->resource_name, $this->resource_object)) {
               throw new SmartyException ("Unable to parse resource name \"{$template_resource}\"");
           }


\"{$template_resource}\"");

should be $this->template_resource ??
[/code]
Back to top
View user's profile Send private message
U.Tews
Administrator


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

PostPosted: Wed Feb 16, 2011 2:16 pm    Post subject: Reply with quote

There was no change on templateExist() and I can't reproduce any error.

Do you have an example how you did use it?


Indeed there is a typo within the exception message. I will update the SVN version.
Back to top
View user's profile Send private message
sskaje
Smarty Rookie


Joined: 12 Nov 2010
Posts: 9

PostPosted: Thu Feb 17, 2011 6:04 am    Post subject: Reply with quote

U.Tews wrote:
There was no change on templateExist() and I can't reproduce any error.

Do you have an example how you did use it?


Indeed there is a typo within the exception message. I will update the SVN version.


I'm trying to debug with zend studio. Till now i found buildTemplateFilepath() has its smarty->default_template_handler_func === null, trying to figure it out.
Back to top
View user's profile Send private message
sskaje
Smarty Rookie


Joined: 12 Nov 2010
Posts: 9

PostPosted: Thu Feb 17, 2011 6:19 am    Post subject: Reply with quote

U.Tews wrote:
There was no change on templateExist() and I can't reproduce any error.

Do you have an example how you did use it?


Indeed there is a typo within the exception message. I will update the SVN version.


I've figured it out.

I render my template using code like
Code:

        $this->display('smarty', '/user/login');


the display handler append a file-ext to the second arg, then do the same thing as a simple smarty invoking.
Code:

$smarty->display('/user/login.tpl');


this works before 3.0.7, but in 3.0.7, only code below works
Code:

        $this->display('smarty', 'user/login');
Back to top
View user's profile Send private message
U.Tews
Administrator


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

PostPosted: Thu Feb 17, 2011 2:39 pm    Post subject: Reply with quote

sskaje wrote:

this works before 3.0.7, but in 3.0.7, only code below works
Code:

        $this->display('smarty', 'user/login');


The above code block is identiacl to the first code block in your last post.

So I still see not what is working and what not.
Back to top
View user's profile Send private message
sskaje
Smarty Rookie


Joined: 12 Nov 2010
Posts: 9

PostPosted: Sun Feb 20, 2011 6:04 pm    Post subject: Reply with quote

U.Tews wrote:
sskaje wrote:

this works before 3.0.7, but in 3.0.7, only code below works
Code:

        $this->display('smarty', 'user/login');


The above code block is identiacl to the first code block in your last post.

So I still see not what is working and what not.


find:
Code:

[root@dev smarty]# find .
.
./1.tpl
./smarty.php
[root@dev smarty]#


code 1:
Code:

$smarty = new Smarty();
$smarty->compile_dir = '/tmp';
$smarty->template_dir = './';

$smarty->assign('msg', 'hello');
$smarty->display('1.tpl');


code 2
Code:

$smarty = new Smarty();
$smarty->compile_dir = '/tmp';
$smarty->template_dir = './';

$smarty->assign('msg', 'hello');
$smarty->display('/1.tpl');


1.tpl:
Code:
{$msg}


result 1:
Quote:
hello


result 2:
Quote:


Fatal error: Uncaught exception 'SmartyException' with message 'Unable to load template file '/1.tpl'' in /var/www/***/spframework/source/externals/Smarty3/libs/sysplugins/smarty_internal_template.php:163 Stack trace: #0 /var/www/***/spframework/source/externals/Smarty3/libs/sysplugins/smarty_internal_template.php(550): Smarty_Internal_Template->isExisting(true) #1 /var/www/***/spframework/source/externals/Smarty3/libs/Smarty.class.php(338): Smarty_Internal_Template->getRenderedTemplate() #2 /var/www/***/spframework/source/externals/Smarty3/libs/Smarty.class.php(382): Smarty->fetch('/1.tpl', NULL, NULL, NULL, true) #3 /var/www/smarty/smarty.php(10): Smarty->display('/1.tpl') #4 {main} thrown in /var/www/***/spframework/source/externals/Smarty3/libs/sysplugins/smarty_internal_template.php on line 163
Back to top
View user's profile Send private message
U.Tews
Administrator


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

PostPosted: Sun Feb 20, 2011 7:13 pm    Post subject: Reply with quote

Sorry I did not see the leading / in your previous post.

Indead there was a change in filename parsing. There was a problem with absolute filepathes on UNIX systems which do start with / .

It's now not a bug, but correct interpretion of a UNIX absolute filepath.
Back to top
View user's profile Send private message
sskaje
Smarty Rookie


Joined: 12 Nov 2010
Posts: 9

PostPosted: Sun Feb 20, 2011 7:39 pm    Post subject: Reply with quote

U.Tews wrote:
Sorry I did not see the leading / in your previous post.

Indead there was a change in filename parsing. There was a problem with absolute filepathes on UNIX systems which do start with / .

It's now not a bug, but correct interpretion of a UNIX absolute filepath.


does that mean the template_dir is not that important like before cos template can read any file readable ?

ps: i tried this
Code:

{$msg}

{include file="/etc/passwd"}

seems to be not that secure.
Back to top
View user's profile Send private message
U.Tews
Administrator


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

PostPosted: Sun Feb 20, 2011 8:00 pm    Post subject: Reply with quote

if security is not enabled you can access any directory.

If security is enabled you can only access template_dir or the folders specified in secure_dir of security.

see http://www.smarty.net/docs/en/advanced.features.tpl#advanced.features.security

The old version could also access an absolute directory, but by mistake it did try to find the template also in template_dir first.
Back to top
View user's profile Send private message
sskaje
Smarty Rookie


Joined: 12 Nov 2010
Posts: 9

PostPosted: Sun Feb 20, 2011 8:17 pm    Post subject: Reply with quote

U.Tews wrote:
if security is not enabled you can access any directory.

If security is enabled you can only access template_dir or the folders specified in secure_dir of security.

see http://www.smarty.net/docs/en/advanced.features.tpl#advanced.features.security

The old version could also access an absolute directory, but by mistake it did try to find the template also in template_dir first.


i see, thx
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