nrueckmann / smarty-php

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

filepath/resource modification bug #129

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
I'm using Smarty v3.1.12 with a vfsStream as template source.
$this->template = vfsStream::url('root/smarty-template.tpl');
$this->template contains "vfs://root/smarty-template.tpl".

You can reproduce the following error by doing $smarty->fetch($this->template); 
:

fopen(vfs:////root/smarty-template.tpl): failed to open stream: 
"org\bovigo\vfs\vfsStreamWrapper::stream_open" call failed

As you can see the template URL is modified to contain 
"vfs:////root/smarty-template.tpl", instead of the expected 
"vfs://root/smarty-template.tpl". So the error is ":////" != "://".
This means that one can not fetch a template via URL.

The modification of the $source->filepath or $source->resource is wrong.

It's done in "smarty_internal_resource_stream.php" on line 33, inside 
populate(): 
$source->filepath = str_replace(':', '://', $source->resource);

Bugfix:
if(strpos($source->resource, '://') !== false) {
    $source->filepath = $source->resource;
} else {
    $source->filepath = str_replace(':', '://', $source->resource);
}

This allows also using "file://template.tpl", etc.

Regards, Jens

Original issue reported on code.google.com by knd.vain on 6 Jan 2013 at 2:39

GoogleCodeExporter commented 8 years ago
Thank's for your input.

This enhancement is now in the SVN trunk and will later be included in the 
3.1.13 release

Original comment by Uwe.Tews@googlemail.com on 6 Jan 2013 at 7:24