cvs: pear-core /PEAR/PackageFile v1.php /PEAR/PackageFile/v2 Validator.php
| From: | Greg Beaver | Date: | Mon, 03 Oct 2005 03:07:57 +0000 |
| Subject: | cvs: pear-core /PEAR/PackageFile v1.php /PEAR/PackageFile/v2 Validator.php | ||
| Groups: | php.pear.cvs php.pear.core | ||
| Request: | Send a blank email to pear-cvs+get-35234@lists.php.net to get a copy of this message | ||
cellog Sun Oct 2 23:07:57 2005 EDT
Modified files:
/pear-core/PEAR/PackageFile v1.php
/pear-core/PEAR/PackageFile/v2 Validator.php
Log:
partial fix for #5576: don't allow package.xml with
<file name="./whatever"> to package
(they can still be installed)
http://cvs.php.net/diff.php/pear-core/PEAR/PackageFile/v1.php?r1=1.61&r2=1.62&ty=u
Index: pear-core/PEAR/PackageFile/v1.php
diff -u pear-core/PEAR/PackageFile/v1.php:1.61 pear-core/PEAR/PackageFile/v1.php:1.62
--- pear-core/PEAR/PackageFile/v1.php:1.61 Sat Sep 24 23:49:00 2005
+++ pear-core/PEAR/PackageFile/v1.php Sun Oct 2 23:07:54 2005
@@ -15,7 +15,7 @@
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2005 The PHP Group
* @license http://www.php.net/license/3_0.txt
PHP License 3.0
- * @version CVS: $Id: v1.php,v 1.61 2005/09/25 03:49:00 cellog Exp $
+ * @version CVS: $Id: v1.php,v 1.62 2005/10/03 03:07:54 cellog Exp $
* @link http://pear.php.net/package/PEAR
* @since File available since Release 1.4.0a1
*/
@@ -269,6 +269,11 @@
* Error code when a package has no lead developer
*/
define('PEAR_PACKAGEFILE_ERROR_NO_LEAD', 51);
+
+/**
+ * Error code when a filename begins with "."
+ */
+define('PEAR_PACKAGEFILE_ERROR_INVALID_FILENAME', 52);
/**
* package.xml encapsulator
* @category pear
@@ -1185,6 +1190,12 @@
$this->_validateError(PEAR_PACKAGEFILE_ERROR_INVALID_FILEROLE,
array('file' => $file, 'role' =>
$fa['role'], 'roles' => PEAR_Common::getFileRoles()));
}
+ if ($state == PEAR_VALIDATE_PACKAGING) {
+ if ($file{0} == '.') {
+ $this->_validateError(PEAR_PACKAGEFILE_ERROR_INVALID_FILENAME,
+ array('file' => $file));
+ }
+ }
}
}
if (isset($this->_registry) && $this->_isValid) {
http://cvs.php.net/diff.php/pear-core/PEAR/PackageFile/v2/Validator.php?r1=1.75&r2=1.76&ty=u
Index: pear-core/PEAR/PackageFile/v2/Validator.php
diff -u pear-core/PEAR/PackageFile/v2/Validator.php:1.75
pear-core/PEAR/PackageFile/v2/Validator.php:1.76
--- pear-core/PEAR/PackageFile/v2/Validator.php:1.75 Sun Oct 2 16:27:26 2005
+++ pear-core/PEAR/PackageFile/v2/Validator.php Sun Oct 2 23:07:57 2005
@@ -17,7 +17,7 @@
// | |
// +----------------------------------------------------------------------+
//
-// $Id: Validator.php,v 1.75 2005/10/02 20:27:26 cellog Exp $
+// $Id: Validator.php,v 1.76 2005/10/03 03:07:57 cellog Exp $
/**
* Private validation class used by PEAR_PackageFile_v2 - do not use directly, its
* sole purpose is to split up the PEAR/PackageFile/v2.php file to make it smaller
@@ -1011,6 +1011,12 @@
}
foreach ($list['file'] as $i => $file)
{
+ if ($this->_curState == PEAR_VALIDATE_PACKAGING &&
+ isset($file['attribs']) &&
isset($file['attribs']['name']) &&
+ $file['attribs']['name']{0} == '.') {
+ // name is something like "./doc/whatever.txt"
+ $this->_invalidFileName($file['attribs']['name']);
+ }
if (isset($file['attribs']) &&
isset($file['attribs']['role'])) {
if (!$this->_validateRole($file['attribs']['role'])) {
if (isset($this->_packageInfo['usesrole'])) {
@@ -1309,6 +1315,13 @@
'File "%file%" in directory "%dir%" has invalid role
"%role%", should be one of %roles%');
}
+ function _invalidFileName($file, $dir)
+ {
+ $this->_stack->push(__FUNCTION__, 'error', array(
+ 'file' => $file, 'dir' => $dir),
+ 'File "%file%" in directory "%dir%" cannot begin with
"."');
+ }
+
function _filelistCannotContainFile($filelist)
{
$this->_stack->push(__FUNCTION__, 'error', array('tag' =>
$filelist),