ranlt / smarty-php

Automatically exported from code.google.com/p/smarty-php
0 stars 0 forks source link

Smarty removes double slashes on Windows servers #142

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
Setup base app with Smarty 3 on the windows server. Try to display template.

What is the expected output? What do you see instead?
Warning: 
file_get_contents(\WEB1.BYFARTHECHEAPEST.NET\F\Users\public_html\csc4\design\the
mes\basic\templates\index.tpl): failed to open stream: No such file or 
directory in 
\\WEB1.BYFARTHECHEAPEST.NET\F\Users\public_html\csc4\app\lib\other\smarty\sysplu
gins\smarty_internal_resource_file.php on line 65

What version of the product are you using? On what operating system?
version 3.1.13

Please provide any additional information below.

Problem in the sysplugins/smarty_resource.php file
function normalizePath

// resolve simples
$_path = preg_replace('#(/\./(\./)*)|/{2,}#', '/', $_path);

$_path before:
//WEB1.BYFARTHECHEAPEST.NET/F/Users/public_html/csc4/design/themes/basic/templat
es/views/index/index.tpl

$_path after: 
/WEB1.BYFARTHECHEAPEST.NET/F/Users/public_html/csc4/design/themes/basic/template
s/views/index/index.tpl

As you can see, there is only one slash at start. But the correct path must 
start from two //
So, template couldn't be found, although this checking works:

 if ($this->fileExists($source, $_filepath)) { //Correct checking, file exists
                    return $this->normalizePath($_filepath); // Path becomes incorrect

Original issue reported on code.google.com by alexio...@gmail.com on 11 Jul 2013 at 7:54

GoogleCodeExporter commented 9 years ago
The fix is now in the SVN trunk and will later be included in 3.1.15

Original comment by Uwe.Tews@googlemail.com on 12 Jul 2013 at 12:20

GoogleCodeExporter commented 9 years ago
Also, guys

public function loadPlugin($plugin_name, $check = true)
....
if ($this->use_include_path && !preg_match('/^([\/\\\\]|[a-zA-Z]:[\/\\\\])/', 
$_plugin_dir)) {
...

Why you exclude windows servers?
The same issue: I tried to use custom modifiers and I failed to do it.

15-Jul-2013 10:51:46 UTC] PHP Warning:  
include(\WEB1.BYFARTHECHEAPEST.NET\F\Users\public_html\csc4\app\lib\other\smarty
\plugins\modifier.date_format.php): failed to open stream: No such file or 
directory in 
\\WEB1.BYFARTHECHEAPEST.NET\F\Users\public_html\csc4\var\cache\templates\design\
backend\templates\dea8c7b03e60f86e7e7ee036c63b006844130bf7.tygh.index.tpl.php 
on line 261

When I removing the first condition ([\/\\\\]), all works fine.

Original comment by alexio...@gmail.com on 19 Jul 2013 at 1:37

GoogleCodeExporter commented 9 years ago
When searching for plugins in the system include path it does only work with 
realtive plugin_dir values as it will be appended to the include_path.

That's why we exclude the search on absolute plugin_dir values because it would 
always fail.

So how did you configure the filepath to plugins_dir.

Actually you are the first user where I have seen the 
'\\WEB1.BYFARTHECHEAPEST.NET\' syntax for defining the filepathes.

Original comment by Uwe.Tews@googlemail.com on 19 Jul 2013 at 7:55