cvs: pear /HTML_Template_PHPLIB/HTML/Template PHPLIB.php /HTML_Template_PHPLIB/tests HTML_Template_PHPLIBTest.php

From: Date: Mon, 01 Oct 2007 15:12:07 +0000
Subject: cvs: pear /HTML_Template_PHPLIB/HTML/Template PHPLIB.php /HTML_Template_PHPLIB/tests HTML_Template_PHPLIBTest.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-48735@lists.php.net to get a copy of this message
cweiske Mon Oct 1 15:12:07 2007 UTC Modified files: /pear/HTML_Template_PHPLIB/HTML/Template PHPLIB.php /pear/HTML_Template_PHPLIB/tests HTML_Template_PHPLIBTest.php Log: Fix bug #11889: function _filename() not works well on Windows http://cvs.php.net/viewvc.cgi/pear/HTML_Template_PHPLIB/HTML/Template/PHPLIB.php?r1=1.3&r2=1.4&diff_format=u Index: pear/HTML_Template_PHPLIB/HTML/Template/PHPLIB.php diff -u pear/HTML_Template_PHPLIB/HTML/Template/PHPLIB.php:1.3 pear/HTML_Template_PHPLIB/HTML/Template/PHPLIB.php:1.4 --- pear/HTML_Template_PHPLIB/HTML/Template/PHPLIB.php:1.3 Sun Jul 8 10:41:39 2007 +++ pear/HTML_Template_PHPLIB/HTML/Template/PHPLIB.php Mon Oct 1 15:12:07 2007 @@ -8,7 +8,7 @@ // Bjoern Schotte <schotte@mayflower.de> (PEARification) // Martin Jansen <mj@php.net> (PEAR conformance) // -// $Id: PHPLIB.php,v 1.3 2007/07/08 10:41:39 cweiske Exp $ +// $Id: PHPLIB.php,v 1.4 2007/10/01 15:12:07 cweiske Exp $ // /** @@ -24,7 +24,7 @@ * @author Bjoern Schotte <schotte@mayflower.de> * @author Martin Jansen <mj@php.net> (PEAR conformance) * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 - * @version CVS: $Id: PHPLIB.php,v 1.3 2007/07/08 10:41:39 cweiske Exp $ + * @version CVS: $Id: PHPLIB.php,v 1.4 2007/10/01 15:12:07 cweiske Exp $ * @link http://pear.php.net/package/HTML_Template_PHPLIB */ class HTML_Template_PHPLIB @@ -507,7 +507,7 @@ */ function _filename($filename) { - if (substr($filename, 0, 1) != '/') { + if (!$this->_isAbsolute($filename)) { $filename = $this->root . '/' . $filename; } @@ -532,6 +532,26 @@ return $filename; } + + + /** + * Tells you whether a filename is absolute or relative + * + * @param string $filename Filename to check + * + * @return boolean true if the filename is absolute + */ + function _isAbsolute($filename) + { + if (substr($filename, 0, 1) == '/') { + //unix + return true; + } else if (substr($filename, 1, 2) == ':\\') { + //windows + return true; + } + return false; + } /** * Protect a replacement variable @@ -645,7 +665,7 @@ * @package HTML_Template_PHPLIB * @author Christian Weiske <cweiske@php.net> * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 - * @version CVS: $Id: PHPLIB.php,v 1.3 2007/07/08 10:41:39 cweiske Exp $ + * @version CVS: $Id: PHPLIB.php,v 1.4 2007/10/01 15:12:07 cweiske Exp $ * @link http://pear.php.net/package/HTML_Template_PHPLIB */ class Template_PHPLIB extends HTML_Template_PHPLIB http://cvs.php.net/viewvc.cgi/pear/HTML_Template_PHPLIB/tests/HTML_Template_PHPLIBTest.php?r1=1.1&r2=1.2&diff_format=u Index: pear/HTML_Template_PHPLIB/tests/HTML_Template_PHPLIBTest.php diff -u pear/HTML_Template_PHPLIB/tests/HTML_Template_PHPLIBTest.php:1.1 pear/HTML_Template_PHPLIB/tests/HTML_Template_PHPLIBTest.php:1.2 --- pear/HTML_Template_PHPLIB/tests/HTML_Template_PHPLIBTest.php:1.1 Sun Jul 8 10:41:39 2007 +++ pear/HTML_Template_PHPLIB/tests/HTML_Template_PHPLIBTest.php Mon Oct 1 15:12:07 2007 @@ -234,6 +234,16 @@ $this->tpl->get('TMP') ); } + + + + public function testIsAbsolute() + { + $this->assertTrue($this->tpl->_isAbsolute('/home/user/project/template.tpl')); + $this->assertTrue($this->tpl->_isAbsolute('C:\\Documents And Settings\\User\\template.tpl')); + $this->assertFalse($this->tpl->_isAbsolute('templates/file.tpl')); + $this->assertFalse($this->tpl->_isAbsolute('./templates/file.tpl')); + } } // Call HTML_Template_PHPLIBTest::main() if this source file is executed directly.

« previous php.pear.cvs (#48735) next »