phingofficial /
phing
This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include, or for example
via PHP's auto-loading mechanism.
| 1 | <?php |
||
| 2 | |||
| 3 | /** |
||
| 4 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
||
| 5 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
||
| 6 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
||
| 7 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
||
| 8 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
||
| 9 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
||
| 10 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
||
| 11 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
||
| 12 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
||
| 13 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
||
| 14 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||
| 15 | * |
||
| 16 | * This software consists of voluntary contributions made by many individuals |
||
| 17 | * and is licensed under the LGPL. For more information please see |
||
| 18 | * <http://phing.info>. |
||
| 19 | */ |
||
| 20 | |||
| 21 | namespace Phing\Parser; |
||
| 22 | |||
| 23 | use Phing\Io\File; |
||
| 24 | use Phing\Util\StringHelper; |
||
| 25 | |||
| 26 | /** |
||
| 27 | * Handler class for the <project> XML element This class handles all elements |
||
| 28 | * under the <project> element. |
||
| 29 | * |
||
| 30 | * @author Andreas Aderhold <[email protected]> |
||
| 31 | * @copyright (c) 2001,2002 THYRELL. All rights reserved |
||
| 32 | */ |
||
| 33 | class ProjectHandler extends AbstractHandler |
||
| 34 | { |
||
| 35 | /** |
||
| 36 | * The phing project configurator object. |
||
| 37 | * |
||
| 38 | * @var ProjectConfigurator |
||
| 39 | */ |
||
| 40 | private $configurator; |
||
| 41 | |||
| 42 | /** |
||
| 43 | * @var XmlContext |
||
| 44 | */ |
||
| 45 | private $context; |
||
| 46 | |||
| 47 | /** |
||
| 48 | * Constructs a new ProjectHandler. |
||
| 49 | * |
||
| 50 | * @param ExpatParser $parser the ExpatParser object |
||
| 51 | * @param AbstractHandler $parentHandler the parent handler that invoked this handler |
||
| 52 | * @param ProjectConfigurator $configurator the ProjectConfigurator object |
||
| 53 | */ |
||
| 54 | 907 | public function __construct( |
|
| 55 | ExpatParser $parser, |
||
| 56 | AbstractHandler $parentHandler, |
||
| 57 | ProjectConfigurator $configurator, |
||
| 58 | XmlContext $context |
||
| 59 | ) { |
||
| 60 | 907 | parent::__construct($parser, $parentHandler); |
|
| 61 | |||
| 62 | 907 | $this->configurator = $configurator; |
|
| 63 | 907 | $this->context = $context; |
|
| 64 | } |
||
| 65 | |||
| 66 | /** |
||
| 67 | * Executes initialization actions required to setup the project. Usually |
||
| 68 | * this method handles the attributes of a tag. |
||
| 69 | * |
||
| 70 | * @param string $tag the tag that comes in |
||
| 71 | * @param array $attrs attributes the tag carries |
||
| 72 | * |
||
| 73 | * @throws ExpatParseException if attributes are incomplete or invalid |
||
| 74 | */ |
||
| 75 | 907 | public function init($tag, $attrs) |
|
|
0 ignored issues
–
show
|
|||
| 76 | { |
||
| 77 | 907 | $def = null; |
|
| 78 | 907 | $name = null; |
|
| 79 | 907 | $id = null; |
|
| 80 | 907 | $desc = null; |
|
| 81 | 907 | $baseDir = null; |
|
| 82 | 907 | $ver = null; |
|
| 83 | 907 | $strict = null; |
|
| 84 | |||
| 85 | // some shorthands |
||
| 86 | 907 | $project = $this->configurator->project; |
|
| 87 | 907 | $buildFileParent = $this->configurator->buildFileParent; |
|
| 88 | |||
| 89 | 907 | foreach ($attrs as $key => $value) { |
|
| 90 | 907 | if ('default' === $key) { |
|
| 91 | 907 | $def = $value; |
|
| 92 | 898 | } elseif ('name' === $key) { |
|
| 93 | 898 | $name = $value; |
|
| 94 | 99 | } elseif ('id' === $key) { |
|
| 95 | $id = $value; |
||
| 96 | 99 | } elseif ('basedir' === $key) { |
|
| 97 | 99 | $baseDir = $value; |
|
| 98 | } elseif ('description' === $key) { |
||
| 99 | $desc = $value; |
||
| 100 | } elseif ('phingVersion' === $key) { |
||
| 101 | $ver = $value; |
||
| 102 | } elseif ('strict' === $key) { |
||
| 103 | $strict = $value; |
||
| 104 | } else { |
||
| 105 | throw new ExpatParseException("Unexpected attribute '{$key}'"); |
||
| 106 | } |
||
| 107 | } |
||
| 108 | // these things get done no matter what |
||
| 109 | 907 | if (null == $name) { |
|
| 110 | 18 | $name = basename($this->configurator->getBuildFile()); |
|
| 111 | } |
||
| 112 | |||
| 113 | 907 | $canonicalName = self::canonicalName($name); |
|
| 114 | 907 | $this->configurator->setCurrentProjectName($canonicalName); |
|
| 115 | 907 | $path = (string) $this->configurator->getBuildFile(); |
|
| 116 | 907 | $project->setUserProperty("phing.file.{$canonicalName}", $path); |
|
| 117 | 907 | $project->setUserProperty("phing.dir.{$canonicalName}", dirname($path)); |
|
| 118 | |||
| 119 | 907 | if ($this->configurator->isIgnoringProjectTag()) { |
|
| 120 | 101 | return; |
|
| 121 | } |
||
| 122 | |||
| 123 | 907 | if (null === $def) { |
|
| 124 | throw new ExpatParseException( |
||
| 125 | 'The default attribute of project is required' |
||
| 126 | ); |
||
| 127 | } |
||
| 128 | |||
| 129 | 907 | $project->setDefaultTarget($def); |
|
| 130 | |||
| 131 | 907 | if (null !== $name) { |
|
| 132 | 907 | $project->setName($name); |
|
| 133 | 907 | $project->addReference($name, $project); |
|
| 134 | } |
||
| 135 | |||
| 136 | 907 | if (null !== $id) { |
|
| 137 | $project->addReference($id, $project); |
||
| 138 | } |
||
| 139 | |||
| 140 | 907 | if (null !== $desc) { |
|
| 141 | $project->setDescription($desc); |
||
| 142 | } |
||
| 143 | |||
| 144 | 907 | if (null !== $ver) { |
|
| 145 | $project->setPhingVersion($ver); |
||
| 146 | } |
||
| 147 | |||
| 148 | 907 | if (null !== $strict) { |
|
| 149 | $project->setStrictMode(StringHelper::booleanValue($strict)); |
||
| 150 | } |
||
| 151 | |||
| 152 | 907 | if (null !== $project->getProperty('project.basedir')) { |
|
| 153 | 26 | $project->setBasedir($project->getProperty('project.basedir')); |
|
| 154 | } else { |
||
| 155 | 907 | if (null === $baseDir) { |
|
| 156 | 809 | $project->setBasedir($buildFileParent->getAbsolutePath()); |
|
| 157 | } else { |
||
| 158 | // check whether the user has specified an absolute path |
||
| 159 | 99 | $f = new File($baseDir); |
|
| 160 | 99 | if ($f->isAbsolute()) { |
|
| 161 | $project->setBasedir($baseDir); |
||
| 162 | } else { |
||
| 163 | 99 | $project->setBaseDir($project->resolveFile($baseDir, $buildFileParent)); |
|
| 164 | } |
||
| 165 | } |
||
| 166 | } |
||
| 167 | |||
| 168 | 907 | $project->addTarget('', $this->context->getImplicitTarget()); |
|
| 169 | } |
||
| 170 | |||
| 171 | /** |
||
| 172 | * Handles start elements within the <project> tag by creating and |
||
| 173 | * calling the required handlers for the detected element. |
||
| 174 | * |
||
| 175 | * @param string $name the tag that comes in |
||
| 176 | * @param array $attrs attributes the tag carries |
||
| 177 | * |
||
| 178 | * @throws ExpatParseException if a unxepected element occurs |
||
| 179 | */ |
||
| 180 | 907 | public function startElement($name, $attrs) |
|
| 181 | { |
||
| 182 | 907 | $project = $this->configurator->project; |
|
| 183 | 907 | $types = $project->getDataTypeDefinitions(); |
|
|
0 ignored issues
–
show
|
|||
| 184 | |||
| 185 | 907 | if ('target' === $name || 'extension-point' === $name) { |
|
| 186 | 907 | $tf = new TargetHandler($this->parser, $this, $this->configurator, $this->context); |
|
| 187 | 907 | $tf->init($name, $attrs); |
|
| 188 | } else { |
||
| 189 | 528 | $tf = new ElementHandler( |
|
| 190 | 528 | $this->parser, |
|
| 191 | 528 | $this, |
|
| 192 | 528 | $this->configurator, |
|
| 193 | 528 | null, |
|
| 194 | 528 | null, |
|
| 195 | 528 | $this->context->getImplicitTarget() |
|
| 196 | 528 | ); |
|
| 197 | 528 | $tf->init($name, $attrs); |
|
| 198 | } |
||
| 199 | } |
||
| 200 | |||
| 201 | /** |
||
| 202 | * @param $name |
||
| 203 | */ |
||
| 204 | 907 | public static function canonicalName($name) |
|
| 205 | { |
||
| 206 | 907 | return preg_replace('/\W/', '_', strtolower($name)); |
|
| 207 | } |
||
| 208 | } |
||
| 209 |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.