Update to PEAR 1.7.2, Image_Canvas 0.3.1, Image_Color 1.0.3, Image_Graph 0.7.2, XML_Parser 1.3.1.
Removed PHP_Compat, and references to it. Removed ionCube/Zend/mmCache compatibility checks in test.php script. Changed minimum PHP requirement to 5.0 in test.php script.
This commit is contained in:
@@ -1,27 +1,35 @@
|
||||
<?php
|
||||
//
|
||||
// +----------------------------------------------------------------------+
|
||||
// | PHP Version 5 |
|
||||
// +----------------------------------------------------------------------+
|
||||
// | Copyright (c) 1997-2004 The PHP Group |
|
||||
// +----------------------------------------------------------------------+
|
||||
// | This source file is subject to version 3.0 of the PHP license, |
|
||||
// | that is bundled with this package in the file LICENSE, and is |
|
||||
// | available through the world-wide-web at the following url: |
|
||||
// | http://www.php.net/license/3_0.txt. |
|
||||
// | If you did not receive a copy of the PHP license and are unable to |
|
||||
// | obtain it through the world-wide-web, please send a note to |
|
||||
// | license@php.net so we can mail you a copy immediately. |
|
||||
// +----------------------------------------------------------------------+
|
||||
// | Author: Greg Beaver <cellog@php.net> |
|
||||
// | |
|
||||
// +----------------------------------------------------------------------+
|
||||
//
|
||||
// $Id: Validator.php,v 1.82 2005/10/27 05:07:24 cellog Exp $
|
||||
/**
|
||||
* PEAR_PackageFile_v2, package.xml version 2.0, read/write version
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
* LICENSE: This source file is subject to version 3.0 of the PHP license
|
||||
* that is available through the world-wide-web at the following URI:
|
||||
* http://www.php.net/license/3_0.txt. If you did not receive a copy of
|
||||
* the PHP License and are unable to obtain it through the web, please
|
||||
* send a note to license@php.net so we can mail you a copy immediately.
|
||||
*
|
||||
* @category pear
|
||||
* @package PEAR
|
||||
* @author Greg Beaver <cellog@php.net>
|
||||
* @copyright 1997-2008 The PHP Group
|
||||
* @license http://www.php.net/license/3_0.txt PHP License 3.0
|
||||
* @version CVS: $Id: Validator.php,v 1.106 2008/03/28 22:23:41 dufuz Exp $
|
||||
* @link http://pear.php.net/package/PEAR
|
||||
* @since File available since Release 1.4.0a8
|
||||
*/
|
||||
/**
|
||||
* 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
|
||||
* @author Greg Beaver <cellog@php.net>
|
||||
* @category pear
|
||||
* @package PEAR
|
||||
* @author Greg Beaver <cellog@php.net>
|
||||
* @copyright 1997-2008 The PHP Group
|
||||
* @license http://www.php.net/license/3_0.txt PHP License 3.0
|
||||
* @version Release: 1.7.2
|
||||
* @link http://pear.php.net/package/PEAR
|
||||
* @since Class available since Release 1.4.0a8
|
||||
* @access private
|
||||
*/
|
||||
class PEAR_PackageFile_v2_Validator
|
||||
@@ -42,6 +50,10 @@ class PEAR_PackageFile_v2_Validator
|
||||
* @var int
|
||||
*/
|
||||
var $_isValid = 0;
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
var $_filesValid = 0;
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
@@ -66,7 +78,9 @@ class PEAR_PackageFile_v2_Validator
|
||||
return false;
|
||||
}
|
||||
if (!isset($this->_packageInfo['attribs']['version']) ||
|
||||
$this->_packageInfo['attribs']['version'] != '2.0') {
|
||||
($this->_packageInfo['attribs']['version'] != '2.0' &&
|
||||
$this->_packageInfo['attribs']['version'] != '2.1')
|
||||
) {
|
||||
$this->_noPackageVersion();
|
||||
}
|
||||
$structure =
|
||||
@@ -95,10 +109,21 @@ class PEAR_PackageFile_v2_Validator
|
||||
// needs a certain package installed in order to implement a role or task
|
||||
'*providesextension',
|
||||
'*srcpackage|*srcuri',
|
||||
'+phprelease|+extsrcrelease|+extbinrelease|bundle', //special validation needed
|
||||
'+phprelease|+extsrcrelease|+extbinrelease|' .
|
||||
'+zendextsrcrelease|+zendextbinrelease|bundle', //special validation needed
|
||||
'*changelog',
|
||||
);
|
||||
$test = $this->_packageInfo;
|
||||
if (isset($test['dependencies']) &&
|
||||
isset($test['dependencies']['required']) &&
|
||||
isset($test['dependencies']['required']['pearinstaller']) &&
|
||||
isset($test['dependencies']['required']['pearinstaller']['min']) &&
|
||||
version_compare('1.7.2',
|
||||
$test['dependencies']['required']['pearinstaller']['min'], '<')
|
||||
) {
|
||||
$this->_pearVersionTooLow($test['dependencies']['required']['pearinstaller']['min']);
|
||||
return false;
|
||||
}
|
||||
// ignore post-installation array fields
|
||||
if (array_key_exists('filelist', $test)) {
|
||||
unset($test['filelist']);
|
||||
@@ -115,18 +140,13 @@ class PEAR_PackageFile_v2_Validator
|
||||
if (array_key_exists('_lastversion', $test)) {
|
||||
unset($test['_lastversion']);
|
||||
}
|
||||
if (!$this->_stupidSchemaValidate($structure,
|
||||
$test, '<package>')) {
|
||||
if (!$this->_stupidSchemaValidate($structure, $test, '<package>')) {
|
||||
return false;
|
||||
}
|
||||
if (empty($this->_packageInfo['name'])) {
|
||||
$this->_tagCannotBeEmpty('name');
|
||||
}
|
||||
if (isset($this->_packageInfo['uri'])) {
|
||||
$test = 'uri';
|
||||
} else {
|
||||
$test = 'channel';
|
||||
}
|
||||
$test = isset($this->_packageInfo['uri']) ? 'uri' :'channel';
|
||||
if (empty($this->_packageInfo[$test])) {
|
||||
$this->_tagCannotBeEmpty($test);
|
||||
}
|
||||
@@ -159,6 +179,9 @@ class PEAR_PackageFile_v2_Validator
|
||||
$this->_validateCompatible();
|
||||
}
|
||||
if (!isset($this->_packageInfo['bundle'])) {
|
||||
if (empty($this->_packageInfo['contents'])) {
|
||||
$this->_tagCannotBeEmpty('contents');
|
||||
}
|
||||
if (!isset($this->_packageInfo['contents']['dir'])) {
|
||||
$this->_filelistMustContainDir('contents');
|
||||
return false;
|
||||
@@ -218,11 +241,16 @@ class PEAR_PackageFile_v2_Validator
|
||||
if ($fail) {
|
||||
return false;
|
||||
}
|
||||
$list = $this->_packageInfo['contents'];
|
||||
if (isset($list['dir']) && is_array($list['dir']) && isset($list['dir'][0])) {
|
||||
$this->_multipleToplevelDirNotAllowed();
|
||||
return $this->_isValid = 0;
|
||||
}
|
||||
$this->_validateFilelist();
|
||||
$this->_validateRelease();
|
||||
if (!$this->_stack->hasErrors()) {
|
||||
$chan = $this->_pf->_registry->getChannel($this->_pf->getChannel(), true);
|
||||
if (!$chan) {
|
||||
if (PEAR::isError($chan)) {
|
||||
$this->_unknownChannel($this->_pf->getChannel());
|
||||
} else {
|
||||
$valpack = $chan->getValidationPackage();
|
||||
@@ -417,6 +445,7 @@ class PEAR_PackageFile_v2_Validator
|
||||
{
|
||||
$ret = array();
|
||||
if (count($pieces = explode('|', $key)) > 1) {
|
||||
$ret['choices'] = array();
|
||||
foreach ($pieces as $piece) {
|
||||
$ret['choices'][] = $this->_processStructure($piece);
|
||||
}
|
||||
@@ -442,21 +471,21 @@ class PEAR_PackageFile_v2_Validator
|
||||
$a = $this->_stupidSchemaValidate($structure, $this->_packageInfo['version'], '<version>');
|
||||
$a &= $this->_stupidSchemaValidate($structure, $this->_packageInfo['stability'], '<stability>');
|
||||
if ($a) {
|
||||
if (!preg_match('/^\d+(?:\.\d+)*(?:[a-zA-Z]+\d*)?$/',
|
||||
if (!preg_match('/^\d+(?:\.\d+)*(?:[a-zA-Z]+\d*)?\\z/',
|
||||
$this->_packageInfo['version']['release'])) {
|
||||
$this->_invalidVersion('release', $this->_packageInfo['version']['release']);
|
||||
}
|
||||
if (!preg_match('/^\d+(?:\.\d+)*(?:[a-zA-Z]+\d*)?$/',
|
||||
if (!preg_match('/^\d+(?:\.\d+)*(?:[a-zA-Z]+\d*)?\\z/',
|
||||
$this->_packageInfo['version']['api'])) {
|
||||
$this->_invalidVersion('api', $this->_packageInfo['version']['api']);
|
||||
}
|
||||
if (!in_array($this->_packageInfo['stability']['release'],
|
||||
array('snapshot', 'devel', 'alpha', 'beta', 'stable'))) {
|
||||
$this->_invalidState('release', $this->_packageinfo['stability']['release']);
|
||||
$this->_invalidState('release', $this->_packageInfo['stability']['release']);
|
||||
}
|
||||
if (!in_array($this->_packageInfo['stability']['api'],
|
||||
array('devel', 'alpha', 'beta', 'stable'))) {
|
||||
$this->_invalidState('api', $this->_packageinfo['stability']['api']);
|
||||
$this->_invalidState('api', $this->_packageInfo['stability']['api']);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -495,17 +524,29 @@ class PEAR_PackageFile_v2_Validator
|
||||
$type = $installcondition ? '<installcondition><php>' : '<dependencies><required><php>';
|
||||
$this->_stupidSchemaValidate($structure, $dep, $type);
|
||||
if (isset($dep['min'])) {
|
||||
if (!preg_match('/^\d+(?:\.\d+)*(?:[a-zA-Z]+\d*)?(?:-[a-zA-Z0-9]+)?$/',
|
||||
if (!preg_match('/^\d+(?:\.\d+)*(?:[a-zA-Z]+\d*)?(?:-[a-zA-Z0-9]+)?\\z/',
|
||||
$dep['min'])) {
|
||||
$this->_invalidVersion($type . '<min>', $dep['min']);
|
||||
}
|
||||
}
|
||||
if (isset($dep['max'])) {
|
||||
if (!preg_match('/^\d+(?:\.\d+)*(?:[a-zA-Z]+\d*)?(?:-[a-zA-Z0-9]+)?$/',
|
||||
if (!preg_match('/^\d+(?:\.\d+)*(?:[a-zA-Z]+\d*)?(?:-[a-zA-Z0-9]+)?\\z/',
|
||||
$dep['max'])) {
|
||||
$this->_invalidVersion($type . '<max>', $dep['max']);
|
||||
}
|
||||
}
|
||||
if (isset($dep['exclude'])) {
|
||||
if (!is_array($dep['exclude'])) {
|
||||
$dep['exclude'] = array($dep['exclude']);
|
||||
}
|
||||
foreach ($dep['exclude'] as $exclude) {
|
||||
if (!preg_match(
|
||||
'/^\d+(?:\.\d+)*(?:[a-zA-Z]+\d*)?(?:-[a-zA-Z0-9]+)?\\z/',
|
||||
$exclude)) {
|
||||
$this->_invalidVersion($type . '<exclude>', $exclude);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function _validatePearinstallerDep($dep)
|
||||
@@ -518,21 +559,21 @@ class PEAR_PackageFile_v2_Validator
|
||||
);
|
||||
$this->_stupidSchemaValidate($structure, $dep, '<dependencies><required><pearinstaller>');
|
||||
if (isset($dep['min'])) {
|
||||
if (!preg_match('/^\d+(?:\.\d+)*(?:[a-zA-Z]+\d*)?$/',
|
||||
if (!preg_match('/^\d+(?:\.\d+)*(?:[a-zA-Z]+\d*)?\\z/',
|
||||
$dep['min'])) {
|
||||
$this->_invalidVersion('<dependencies><required><pearinstaller><min>',
|
||||
$dep['min']);
|
||||
}
|
||||
}
|
||||
if (isset($dep['max'])) {
|
||||
if (!preg_match('/^\d+(?:\.\d+)*(?:[a-zA-Z]+\d*)?$/',
|
||||
if (!preg_match('/^\d+(?:\.\d+)*(?:[a-zA-Z]+\d*)?\\z/',
|
||||
$dep['max'])) {
|
||||
$this->_invalidVersion('<dependencies><required><pearinstaller><max>',
|
||||
$dep['max']);
|
||||
}
|
||||
}
|
||||
if (isset($dep['recommended'])) {
|
||||
if (!preg_match('/^\d+(?:\.\d+)*(?:[a-zA-Z]+\d*)?$/',
|
||||
if (!preg_match('/^\d+(?:\.\d+)*(?:[a-zA-Z]+\d*)?\\z/',
|
||||
$dep['recommended'])) {
|
||||
$this->_invalidVersion('<dependencies><required><pearinstaller><recommended>',
|
||||
$dep['recommended']);
|
||||
@@ -543,7 +584,7 @@ class PEAR_PackageFile_v2_Validator
|
||||
$dep['exclude'] = array($dep['exclude']);
|
||||
}
|
||||
foreach ($dep['exclude'] as $exclude) {
|
||||
if (!preg_match('/^\d+(?:\.\d+)*(?:[a-zA-Z]+\d*)?$/',
|
||||
if (!preg_match('/^\d+(?:\.\d+)*(?:[a-zA-Z]+\d*)?\\z/',
|
||||
$exclude)) {
|
||||
$this->_invalidVersion('<dependencies><required><pearinstaller><exclude>',
|
||||
$exclude);
|
||||
@@ -605,19 +646,19 @@ class PEAR_PackageFile_v2_Validator
|
||||
$this->_DepchannelCannotBeUri('<dependencies>' . $group . $type);
|
||||
}
|
||||
if (isset($dep['min'])) {
|
||||
if (!preg_match('/^\d+(?:\.\d+)*(?:[a-zA-Z]+\d*)?$/',
|
||||
if (!preg_match('/^\d+(?:\.\d+)*(?:[a-zA-Z]+\d*)?\\z/',
|
||||
$dep['min'])) {
|
||||
$this->_invalidVersion('<dependencies>' . $group . $type . '<min>', $dep['min']);
|
||||
}
|
||||
}
|
||||
if (isset($dep['max'])) {
|
||||
if (!preg_match('/^\d+(?:\.\d+)*(?:[a-zA-Z]+\d*)?$/',
|
||||
if (!preg_match('/^\d+(?:\.\d+)*(?:[a-zA-Z]+\d*)?\\z/',
|
||||
$dep['max'])) {
|
||||
$this->_invalidVersion('<dependencies>' . $group . $type . '<max>', $dep['max']);
|
||||
}
|
||||
}
|
||||
if (isset($dep['recommended'])) {
|
||||
if (!preg_match('/^\d+(?:\.\d+)*(?:[a-zA-Z]+\d*)?$/',
|
||||
if (!preg_match('/^\d+(?:\.\d+)*(?:[a-zA-Z]+\d*)?\\z/',
|
||||
$dep['recommended'])) {
|
||||
$this->_invalidVersion('<dependencies>' . $group . $type . '<recommended>',
|
||||
$dep['recommended']);
|
||||
@@ -628,7 +669,7 @@ class PEAR_PackageFile_v2_Validator
|
||||
$dep['exclude'] = array($dep['exclude']);
|
||||
}
|
||||
foreach ($dep['exclude'] as $exclude) {
|
||||
if (!preg_match('/^\d+(?:\.\d+)*(?:[a-zA-Z]+\d*)?$/',
|
||||
if (!preg_match('/^\d+(?:\.\d+)*(?:[a-zA-Z]+\d*)?\\z/',
|
||||
$exclude)) {
|
||||
$this->_invalidVersion('<dependencies>' . $group . $type . '<exclude>',
|
||||
$exclude);
|
||||
@@ -641,10 +682,10 @@ class PEAR_PackageFile_v2_Validator
|
||||
{
|
||||
$this->_validatePackageDep($dep, $group, '<subpackage>');
|
||||
if (isset($dep['providesextension'])) {
|
||||
$this->_subpackageCannotProvideExtension(@$dep['name']);
|
||||
$this->_subpackageCannotProvideExtension(isset($dep['name']) ? $dep['name'] : '');
|
||||
}
|
||||
if (isset($dep['conflicts'])) {
|
||||
$this->_subpackagesCannotConflict(@$dep['name']);
|
||||
$this->_subpackagesCannotConflict(isset($dep['name']) ? $dep['name'] : '');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -677,19 +718,19 @@ class PEAR_PackageFile_v2_Validator
|
||||
}
|
||||
$this->_stupidSchemaValidate($structure, $dep, $type);
|
||||
if (isset($dep['min'])) {
|
||||
if (!preg_match('/^\d+(?:\.\d+)*(?:[a-zA-Z]+\d*)?$/',
|
||||
if (!preg_match('/^\d+(?:\.\d+)*(?:[a-zA-Z]+\d*)?\\z/',
|
||||
$dep['min'])) {
|
||||
$this->_invalidVersion(substr($type, 1) . '<min', $dep['min']);
|
||||
}
|
||||
}
|
||||
if (isset($dep['max'])) {
|
||||
if (!preg_match('/^\d+(?:\.\d+)*(?:[a-zA-Z]+\d*)?$/',
|
||||
if (!preg_match('/^\d+(?:\.\d+)*(?:[a-zA-Z]+\d*)?\\z/',
|
||||
$dep['max'])) {
|
||||
$this->_invalidVersion(substr($type, 1) . '<max', $dep['max']);
|
||||
}
|
||||
}
|
||||
if (isset($dep['recommended'])) {
|
||||
if (!preg_match('/^\d+(?:\.\d+)*(?:[a-zA-Z]+\d*)?$/',
|
||||
if (!preg_match('/^\d+(?:\.\d+)*(?:[a-zA-Z]+\d*)?\\z/',
|
||||
$dep['recommended'])) {
|
||||
$this->_invalidVersion(substr($type, 1) . '<recommended', $dep['recommended']);
|
||||
}
|
||||
@@ -699,7 +740,7 @@ class PEAR_PackageFile_v2_Validator
|
||||
$dep['exclude'] = array($dep['exclude']);
|
||||
}
|
||||
foreach ($dep['exclude'] as $exclude) {
|
||||
if (!preg_match('/^\d+(?:\.\d+)*(?:[a-zA-Z]+\d*)?$/',
|
||||
if (!preg_match('/^\d+(?:\.\d+)*(?:[a-zA-Z]+\d*)?\\z/',
|
||||
$exclude)) {
|
||||
$this->_invalidVersion(substr($type, 1) . '<exclude', $exclude);
|
||||
}
|
||||
@@ -896,13 +937,13 @@ class PEAR_PackageFile_v2_Validator
|
||||
}
|
||||
$this->_stupidSchemaValidate($required, $package, $type);
|
||||
if (is_array($package) && array_key_exists('min', $package)) {
|
||||
if (!preg_match('/^\d+(?:\.\d+)*(?:[a-zA-Z]+\d*)?$/',
|
||||
if (!preg_match('/^\d+(?:\.\d+)*(?:[a-zA-Z]+\d*)?\\z/',
|
||||
$package['min'])) {
|
||||
$this->_invalidVersion(substr($type, 1) . '<min', $package['min']);
|
||||
}
|
||||
}
|
||||
if (is_array($package) && array_key_exists('max', $package)) {
|
||||
if (!preg_match('/^\d+(?:\.\d+)*(?:[a-zA-Z]+\d*)?$/',
|
||||
if (!preg_match('/^\d+(?:\.\d+)*(?:[a-zA-Z]+\d*)?\\z/',
|
||||
$package['max'])) {
|
||||
$this->_invalidVersion(substr($type, 1) . '<max', $package['max']);
|
||||
}
|
||||
@@ -912,7 +953,7 @@ class PEAR_PackageFile_v2_Validator
|
||||
$package['exclude'] = array($package['exclude']);
|
||||
}
|
||||
foreach ($package['exclude'] as $exclude) {
|
||||
if (!preg_match('/^\d+(?:\.\d+)*(?:[a-zA-Z]+\d*)?$/',
|
||||
if (!preg_match('/^\d+(?:\.\d+)*(?:[a-zA-Z]+\d*)?\\z/',
|
||||
$exclude)) {
|
||||
$this->_invalidVersion(substr($type, 1) . '<exclude', $exclude);
|
||||
}
|
||||
@@ -971,9 +1012,15 @@ class PEAR_PackageFile_v2_Validator
|
||||
$dirname = $iscontents ? '<contents>' : $unknown;
|
||||
} else {
|
||||
$dirname = '<dir name="' . $list['attribs']['name'] . '">';
|
||||
if (preg_match('~/\.\.?(/|\\z)|^\.\.?/~',
|
||||
str_replace('\\', '/', $list['attribs']['name']))) {
|
||||
// file contains .. parent directory or . cur directory
|
||||
$this->_invalidDirName($list['attribs']['name']);
|
||||
}
|
||||
}
|
||||
$res = $this->_stupidSchemaValidate($struc, $list, $dirname);
|
||||
if ($allowignore && $res) {
|
||||
$ignored_or_installed = array();
|
||||
$this->_pf->getFilelist();
|
||||
$fcontents = $this->_pf->getContents();
|
||||
$filelist = array();
|
||||
@@ -990,6 +1037,20 @@ class PEAR_PackageFile_v2_Validator
|
||||
foreach ($list['install'] as $file) {
|
||||
if (!isset($filelist[$file['attribs']['name']])) {
|
||||
$this->_notInContents($file['attribs']['name'], 'install');
|
||||
continue;
|
||||
}
|
||||
if (array_key_exists($file['attribs']['name'], $ignored_or_installed)) {
|
||||
$this->_multipleInstallAs($file['attribs']['name']);
|
||||
}
|
||||
if (!isset($ignored_or_installed[$file['attribs']['name']])) {
|
||||
$ignored_or_installed[$file['attribs']['name']] = array();
|
||||
}
|
||||
$ignored_or_installed[$file['attribs']['name']][] = 1;
|
||||
if (preg_match('~/\.\.?(/|\\z)|^\.\.?/~',
|
||||
str_replace('\\', '/', $file['attribs']['as']))) {
|
||||
// file contains .. parent directory or . cur directory references
|
||||
$this->_invalidFileInstallAs($file['attribs']['name'],
|
||||
$file['attribs']['as']);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1000,22 +1061,36 @@ class PEAR_PackageFile_v2_Validator
|
||||
foreach ($list['ignore'] as $file) {
|
||||
if (!isset($filelist[$file['attribs']['name']])) {
|
||||
$this->_notInContents($file['attribs']['name'], 'ignore');
|
||||
continue;
|
||||
}
|
||||
if (array_key_exists($file['attribs']['name'], $ignored_or_installed)) {
|
||||
$this->_ignoreAndInstallAs($file['attribs']['name']);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!$allowignore && isset($list['file'])) {
|
||||
if (is_string($list['file'])) {
|
||||
$this->_oldStyleFileNotAllowed();
|
||||
return false;
|
||||
}
|
||||
if (!isset($list['file'][0])) {
|
||||
// single file
|
||||
$list['file'] = array($list['file']);
|
||||
}
|
||||
foreach ($list['file'] as $i => $file)
|
||||
{
|
||||
if (isset($file['attribs']) && isset($file['attribs']['name']) &&
|
||||
$file['attribs']['name']{0} == '.' &&
|
||||
$file['attribs']['name']{1} == '/') {
|
||||
// name is something like "./doc/whatever.txt"
|
||||
$this->_invalidFileName($file['attribs']['name']);
|
||||
if (isset($file['attribs']) && isset($file['attribs']['name'])) {
|
||||
if ($file['attribs']['name']{0} == '.' &&
|
||||
$file['attribs']['name']{1} == '/') {
|
||||
// name is something like "./doc/whatever.txt"
|
||||
$this->_invalidFileName($file['attribs']['name'], $dirname);
|
||||
}
|
||||
if (preg_match('~/\.\.?(/|\\z)|^\.\.?/~',
|
||||
str_replace('\\', '/', $file['attribs']['name']))) {
|
||||
// file contains .. parent directory or . cur directory
|
||||
$this->_invalidFileName($file['attribs']['name'], $dirname);
|
||||
}
|
||||
}
|
||||
if (isset($file['attribs']) && isset($file['attribs']['role'])) {
|
||||
if (!$this->_validateRole($file['attribs']['role'])) {
|
||||
@@ -1064,7 +1139,8 @@ class PEAR_PackageFile_v2_Validator
|
||||
$ret = call_user_func(array($tagClass, 'validateXml'),
|
||||
$this->_pf, $v, $this->_pf->_config, $save);
|
||||
if (is_array($ret)) {
|
||||
$this->_invalidTask($task, $ret, @$save['name']);
|
||||
$this->_invalidTask($task, $ret, isset($save['name']) ?
|
||||
$save['name'] : '');
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -1164,64 +1240,68 @@ class PEAR_PackageFile_v2_Validator
|
||||
), $rel, '<phprelease>');
|
||||
}
|
||||
}
|
||||
if (isset($this->_packageInfo['extsrcrelease'])) {
|
||||
$release = 'extsrcrelease';
|
||||
if (!isset($this->_packageInfo['providesextension'])) {
|
||||
$this->_mustProvideExtension($release);
|
||||
}
|
||||
if (isset($this->_packageInfo['srcpackage']) || isset($this->_packageInfo['srcuri'])) {
|
||||
$this->_cannotHaveSrcpackage($release);
|
||||
}
|
||||
$releases = $this->_packageInfo['extsrcrelease'];
|
||||
if (!is_array($releases)) {
|
||||
return true;
|
||||
}
|
||||
if (!isset($releases[0])) {
|
||||
$releases = array($releases);
|
||||
}
|
||||
foreach ($releases as $rel) {
|
||||
$this->_stupidSchemaValidate(array(
|
||||
'*installconditions',
|
||||
'*configureoption->name->prompt->?default',
|
||||
'*binarypackage',
|
||||
'*filelist',
|
||||
), $rel, '<extsrcrelease>');
|
||||
if (isset($rel['binarypackage'])) {
|
||||
if (!is_array($rel['binarypackage']) || !isset($rel['binarypackage'][0])) {
|
||||
$rel['binarypackage'] = array($rel['binarypackage']);
|
||||
}
|
||||
foreach ($rel['binarypackage'] as $bin) {
|
||||
if (!is_string($bin)) {
|
||||
$this->_binaryPackageMustBePackagename();
|
||||
foreach (array('', 'zend') as $prefix) {
|
||||
$releasetype = $prefix . 'extsrcrelease';
|
||||
if (isset($this->_packageInfo[$releasetype])) {
|
||||
$release = $releasetype;
|
||||
if (!isset($this->_packageInfo['providesextension'])) {
|
||||
$this->_mustProvideExtension($release);
|
||||
}
|
||||
if (isset($this->_packageInfo['srcpackage']) || isset($this->_packageInfo['srcuri'])) {
|
||||
$this->_cannotHaveSrcpackage($release);
|
||||
}
|
||||
$releases = $this->_packageInfo[$releasetype];
|
||||
if (!is_array($releases)) {
|
||||
return true;
|
||||
}
|
||||
if (!isset($releases[0])) {
|
||||
$releases = array($releases);
|
||||
}
|
||||
foreach ($releases as $rel) {
|
||||
$this->_stupidSchemaValidate(array(
|
||||
'*installconditions',
|
||||
'*configureoption->name->prompt->?default',
|
||||
'*binarypackage',
|
||||
'*filelist',
|
||||
), $rel, '<' . $releasetype . '>');
|
||||
if (isset($rel['binarypackage'])) {
|
||||
if (!is_array($rel['binarypackage']) || !isset($rel['binarypackage'][0])) {
|
||||
$rel['binarypackage'] = array($rel['binarypackage']);
|
||||
}
|
||||
foreach ($rel['binarypackage'] as $bin) {
|
||||
if (!is_string($bin)) {
|
||||
$this->_binaryPackageMustBePackagename();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (isset($this->_packageInfo['extbinrelease'])) {
|
||||
$release = 'extbinrelease';
|
||||
if (!isset($this->_packageInfo['providesextension'])) {
|
||||
$this->_mustProvideExtension($release);
|
||||
}
|
||||
if (isset($this->_packageInfo['channel']) &&
|
||||
!isset($this->_packageInfo['srcpackage'])) {
|
||||
$this->_mustSrcPackage($release);
|
||||
}
|
||||
if (isset($this->_packageInfo['uri']) && !isset($this->_packageInfo['srcuri'])) {
|
||||
$this->_mustSrcuri($release);
|
||||
}
|
||||
$releases = $this->_packageInfo['extbinrelease'];
|
||||
if (!is_array($releases)) {
|
||||
return true;
|
||||
}
|
||||
if (!isset($releases[0])) {
|
||||
$releases = array($releases);
|
||||
}
|
||||
foreach ($releases as $rel) {
|
||||
$this->_stupidSchemaValidate(array(
|
||||
'*installconditions',
|
||||
'*filelist',
|
||||
), $rel, '<extbinrelease>');
|
||||
$releasetype = 'extbinrelease';
|
||||
if (isset($this->_packageInfo[$releasetype])) {
|
||||
$release = $releasetype;
|
||||
if (!isset($this->_packageInfo['providesextension'])) {
|
||||
$this->_mustProvideExtension($release);
|
||||
}
|
||||
if (isset($this->_packageInfo['channel']) &&
|
||||
!isset($this->_packageInfo['srcpackage'])) {
|
||||
$this->_mustSrcPackage($release);
|
||||
}
|
||||
if (isset($this->_packageInfo['uri']) && !isset($this->_packageInfo['srcuri'])) {
|
||||
$this->_mustSrcuri($release);
|
||||
}
|
||||
$releases = $this->_packageInfo[$releasetype];
|
||||
if (!is_array($releases)) {
|
||||
return true;
|
||||
}
|
||||
if (!isset($releases[0])) {
|
||||
$releases = array($releases);
|
||||
}
|
||||
foreach ($releases as $rel) {
|
||||
$this->_stupidSchemaValidate(array(
|
||||
'*installconditions',
|
||||
'*filelist',
|
||||
), $rel, '<' . $releasetype . '>');
|
||||
}
|
||||
}
|
||||
}
|
||||
if (isset($this->_packageInfo['bundle'])) {
|
||||
@@ -1250,7 +1330,7 @@ class PEAR_PackageFile_v2_Validator
|
||||
}
|
||||
if (is_array($rel) && array_key_exists('filelist', $rel)) {
|
||||
if ($rel['filelist']) {
|
||||
|
||||
|
||||
$this->_validateFilelist($rel['filelist'], true);
|
||||
}
|
||||
}
|
||||
@@ -1266,6 +1346,14 @@ class PEAR_PackageFile_v2_Validator
|
||||
return in_array($role, PEAR_Installer_Role::getValidRoles($this->_pf->getPackageType()));
|
||||
}
|
||||
|
||||
function _pearVersionTooLow($version)
|
||||
{
|
||||
$this->_stack->push(__FUNCTION__, 'error',
|
||||
array('version' => $version),
|
||||
'This package.xml requires PEAR version %version% to parse properly, we are ' .
|
||||
'version 1.7.2');
|
||||
}
|
||||
|
||||
function _invalidTagOrder($oktags, $actual, $root)
|
||||
{
|
||||
$this->_stack->push(__FUNCTION__, 'error',
|
||||
@@ -1277,7 +1365,7 @@ class PEAR_PackageFile_v2_Validator
|
||||
{
|
||||
$this->_stack->push(__FUNCTION__, 'error', array('type' => $type),
|
||||
'<%type%> is not allowed inside global <contents>, only inside ' .
|
||||
'<phprelease>/<extbinrelease>, use <dir> and <file> only');
|
||||
'<phprelease>/<extbinrelease>/<zendextbinrelease>, use <dir> and <file> only');
|
||||
}
|
||||
|
||||
function _fileNotAllowed($type)
|
||||
@@ -1287,6 +1375,13 @@ class PEAR_PackageFile_v2_Validator
|
||||
'<contents>, use <ignore> and <install> only');
|
||||
}
|
||||
|
||||
function _oldStyleFileNotAllowed()
|
||||
{
|
||||
$this->_stack->push(__FUNCTION__, 'error', array(),
|
||||
'Old-style <file>name</file> is not allowed. Use' .
|
||||
'<file name="name" role="role"/>');
|
||||
}
|
||||
|
||||
function _tagMissingAttribute($tag, $attr, $context)
|
||||
{
|
||||
$this->_stack->push(__FUNCTION__, 'error', array('tag' => $tag,
|
||||
@@ -1319,7 +1414,21 @@ class PEAR_PackageFile_v2_Validator
|
||||
{
|
||||
$this->_stack->push(__FUNCTION__, 'error', array(
|
||||
'file' => $file),
|
||||
'File "%file%" cannot begin with "."');
|
||||
'File "%file%" in directory "%dir%" cannot begin with "./" or contain ".."');
|
||||
}
|
||||
|
||||
function _invalidFileInstallAs($file, $as)
|
||||
{
|
||||
$this->_stack->push(__FUNCTION__, 'error', array(
|
||||
'file' => $file, 'as' => $as),
|
||||
'File "%file%" <install as="%as%"/> cannot contain "./" or contain ".."');
|
||||
}
|
||||
|
||||
function _invalidDirName($dir)
|
||||
{
|
||||
$this->_stack->push(__FUNCTION__, 'error', array(
|
||||
'dir' => $file),
|
||||
'Directory "%dir%" cannot begin with "./" or contain ".."');
|
||||
}
|
||||
|
||||
function _filelistCannotContainFile($filelist)
|
||||
@@ -1481,7 +1590,7 @@ class PEAR_PackageFile_v2_Validator
|
||||
function _cannotProvideExtension($release)
|
||||
{
|
||||
$this->_stack->push(__FUNCTION__, 'error', array('release' => $release),
|
||||
'<%release%> packages cannot use <providesextension>, only extbinrelease and extsrcrelease can provide a PHP extension');
|
||||
'<%release%> packages cannot use <providesextension>, only extbinrelease, extsrcrelease, zendextsrcrelease, and zendextbinrelease can provide a PHP extension');
|
||||
}
|
||||
|
||||
function _mustProvideExtension($release)
|
||||
@@ -1499,13 +1608,13 @@ class PEAR_PackageFile_v2_Validator
|
||||
function _mustSrcPackage($release)
|
||||
{
|
||||
$this->_stack->push(__FUNCTION__, 'error', array('release' => $release),
|
||||
'<extbinrelease> packages must specify a source code package with <srcpackage>');
|
||||
'<extbinrelease>/<zendextbinrelease> packages must specify a source code package with <srcpackage>');
|
||||
}
|
||||
|
||||
function _mustSrcuri($release)
|
||||
{
|
||||
$this->_stack->push(__FUNCTION__, 'error', array('release' => $release),
|
||||
'<extbinrelease> packages must specify a source code package with <srcuri>');
|
||||
'<extbinrelease>/<zendextbinrelease> packages must specify a source code package with <srcuri>');
|
||||
}
|
||||
|
||||
function _uriDepsCannotHaveVersioning($type)
|
||||
@@ -1539,7 +1648,7 @@ class PEAR_PackageFile_v2_Validator
|
||||
{
|
||||
$this->_stack->push(__FUNCTION__, 'error', array(),
|
||||
'<binarypackage> tags must contain the name of a package that is ' .
|
||||
'a compiled version of this extsrc package');
|
||||
'a compiled version of this extsrc/zendextsrc package');
|
||||
}
|
||||
|
||||
function _fileNotFound($file)
|
||||
@@ -1563,13 +1672,13 @@ class PEAR_PackageFile_v2_Validator
|
||||
function _usesroletaskMustHaveChannelOrUri($role, $tag)
|
||||
{
|
||||
$this->_stack->push(__FUNCTION__, 'error', array('role' => $role, 'tag' => $tag),
|
||||
'<%tag%> must contain either <uri>, or <channel> and <package>');
|
||||
'<%tag%> for role "%role%" must contain either <uri>, or <channel> and <package>');
|
||||
}
|
||||
|
||||
function _usesroletaskMustHavePackage($role, $tag)
|
||||
{
|
||||
$this->_stack->push(__FUNCTION__, 'error', array('role' => $role, 'tag' => $tag),
|
||||
'<%tag%> must contain <package>');
|
||||
'<%tag%> for role "%role%" must contain <package>');
|
||||
}
|
||||
|
||||
function _usesroletaskMustHaveRoleTask($tag, $type)
|
||||
@@ -1586,10 +1695,29 @@ class PEAR_PackageFile_v2_Validator
|
||||
|
||||
function _invalidDepGroupName($name)
|
||||
{
|
||||
$this->_stack->push(__FUNCTION__, 'error', array('group' => $name),
|
||||
$this->_stack->push(__FUNCTION__, 'error', array('name' => $name),
|
||||
'Invalid dependency group name "%name%"');
|
||||
}
|
||||
|
||||
function _multipleToplevelDirNotAllowed()
|
||||
{
|
||||
$this->_stack->push(__FUNCTION__, 'error', array(),
|
||||
'Multiple top-level <dir> tags are not allowed. Enclose them ' .
|
||||
'in a <dir name="/">');
|
||||
}
|
||||
|
||||
function _multipleInstallAs($file)
|
||||
{
|
||||
$this->_stack->push(__FUNCTION__, 'error', array('file' => $file),
|
||||
'Only one <install> tag is allowed for file "%file%"');
|
||||
}
|
||||
|
||||
function _ignoreAndInstallAs($file)
|
||||
{
|
||||
$this->_stack->push(__FUNCTION__, 'error', array('file' => $file),
|
||||
'Cannot have both <ignore> and <install> tags for file "%file%"');
|
||||
}
|
||||
|
||||
function _analyzeBundledPackages()
|
||||
{
|
||||
if (!$this->_isValid) {
|
||||
@@ -1602,8 +1730,9 @@ class PEAR_PackageFile_v2_Validator
|
||||
return false;
|
||||
}
|
||||
$dir_prefix = dirname($this->_pf->_packageFile);
|
||||
$common = new PEAR_Common;
|
||||
$log = isset($this->_pf->_logger) ? array(&$this->_pf->_logger, 'log') :
|
||||
array('PEAR_Common', 'log');
|
||||
array($common, 'log');
|
||||
$info = $this->_pf->getContents();
|
||||
$info = $info['bundledpackage'];
|
||||
if (!is_array($info)) {
|
||||
@@ -1650,6 +1779,10 @@ class PEAR_PackageFile_v2_Validator
|
||||
$log = isset($this->_pf->_logger) ? array(&$this->_pf->_logger, 'log') :
|
||||
array(&$common, 'log');
|
||||
$info = $this->_pf->getContents();
|
||||
if (!$info || !isset($info['dir']['file'])) {
|
||||
$this->_tagCannotBeEmpty('contents><dir');
|
||||
return false;
|
||||
}
|
||||
$info = $info['dir']['file'];
|
||||
if (isset($info['attribs'])) {
|
||||
$info = array($info);
|
||||
@@ -1709,6 +1842,8 @@ class PEAR_PackageFile_v2_Validator
|
||||
function analyzeSourceCode($file, $string = false)
|
||||
{
|
||||
if (!function_exists("token_get_all")) {
|
||||
$this->_stack->push(__FUNCTION__, 'error', array('file' => $file),
|
||||
'Parser error: token_get_all() function must exist to analyze source code, PHP may have been compiled with --disable-tokenizer');
|
||||
return false;
|
||||
}
|
||||
if (!defined('T_DOC_COMMENT')) {
|
||||
@@ -1726,15 +1861,20 @@ class PEAR_PackageFile_v2_Validator
|
||||
if (!$fp = @fopen($file, "r")) {
|
||||
return false;
|
||||
}
|
||||
if (function_exists('file_get_contents')) {
|
||||
fclose($fp);
|
||||
$contents = file_get_contents($file);
|
||||
} else {
|
||||
$contents = @fread($fp, filesize($file));
|
||||
fclose($fp);
|
||||
}
|
||||
fclose($fp);
|
||||
$contents = file_get_contents($file);
|
||||
}
|
||||
|
||||
// Silence this function so we can catch PHP Warnings and show our own custom message
|
||||
$tokens = @token_get_all($contents);
|
||||
if (isset($php_errormsg)) {
|
||||
$pn = $this->_pf->getPackage();
|
||||
$this->_stack->push(__FUNCTION__, 'warning',
|
||||
array('file' => $file, 'package' => $pn),
|
||||
'in %file%: Could not process file for unkown reasons,' .
|
||||
' possibly a PHP parse error in %file% from %package%');
|
||||
|
||||
}
|
||||
$tokens = token_get_all($contents);
|
||||
/*
|
||||
for ($i = 0; $i < sizeof($tokens); $i++) {
|
||||
@list($token, $data) = $tokens[$i];
|
||||
@@ -1831,7 +1971,7 @@ class PEAR_PackageFile_v2_Validator
|
||||
if (version_compare(zend_version(), '2.0', '<')) {
|
||||
if (in_array(strtolower($data),
|
||||
array('public', 'private', 'protected', 'abstract',
|
||||
'interface', 'implements', 'throw')
|
||||
'interface', 'implements', 'throw')
|
||||
)) {
|
||||
$this->_stack->push(__FUNCTION__, 'warning', array(
|
||||
'file' => $file),
|
||||
|
Reference in New Issue
Block a user