View previous topic :: View next topic |
Author |
Message |
sskaje Smarty Rookie
Joined: 12 Nov 2010 Posts: 9
|
Posted: Wed Feb 16, 2011 7:56 am Post subject: templateExists return false on 3.0.7 |
|
|
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 |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
Posted: Wed Feb 16, 2011 2:16 pm Post subject: |
|
|
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 |
|
sskaje Smarty Rookie
Joined: 12 Nov 2010 Posts: 9
|
Posted: Thu Feb 17, 2011 6:04 am Post subject: |
|
|
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 |
|
sskaje Smarty Rookie
Joined: 12 Nov 2010 Posts: 9
|
Posted: Thu Feb 17, 2011 6:19 am Post subject: |
|
|
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 |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
Posted: Thu Feb 17, 2011 2:39 pm Post subject: |
|
|
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 |
|
sskaje Smarty Rookie
Joined: 12 Nov 2010 Posts: 9
|
Posted: Sun Feb 20, 2011 6:04 pm Post subject: |
|
|
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:
result 1:
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 |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
Posted: Sun Feb 20, 2011 7:13 pm Post subject: |
|
|
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 |
|
sskaje Smarty Rookie
Joined: 12 Nov 2010 Posts: 9
|
Posted: Sun Feb 20, 2011 7:39 pm Post subject: |
|
|
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 |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
Posted: Sun Feb 20, 2011 8:00 pm Post subject: |
|
|
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 |
|
sskaje Smarty Rookie
Joined: 12 Nov 2010 Posts: 9
|
Posted: Sun Feb 20, 2011 8:17 pm Post subject: |
|
|
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 |
|
|