1
0
Fork 0

Add warning for invalid chars in package names

pull/1352/head
Jordi Boggiano 2012-11-22 19:50:27 +01:00
parent 2de2e953c0
commit da5ee6e2d7
2 changed files with 9 additions and 0 deletions

View File

@ -95,6 +95,12 @@ class Problem
return "\n - The requested linked library ".$job['packageName'].$this->constraintToText($job['constraint']).' has the wrong version installed or is missing from your system, make sure to have the extension providing it.';
}
if (!preg_match('{^[A-Za-z0-9_./-]+$}', $job['packageName'])) {
$illegalChars = preg_replace('{[A-Za-z0-9_./-]+}', '', $job['packageName']);
return "\n - The requested package ".$job['packageName'].' could not be found, it looks like its name is invalid, "'.$illegalChars.'" is not allowed in package names.';
}
if (!$this->pool->whatProvides($job['packageName'])) {
return "\n - The requested package ".$job['packageName'].' could not be found in any version, there may be a typo in the package name.';
}

View File

@ -145,6 +145,9 @@ class ValidatingArrayLoader implements LoaderInterface
foreach (array_keys(BasePackage::$supportedLinkTypes) as $linkType) {
if ($this->validateArray($linkType) && isset($this->config[$linkType])) {
foreach ($this->config[$linkType] as $package => $constraint) {
if (!preg_match('{^[A-Za-z0-9_./-]+$}', $package)) {
$this->warnings[] = $linkType.'.'.$package.' : invalid key, package names must be strings containing only [A-Za-z0-9_./-]';
}
if (!is_string($constraint)) {
$this->errors[] = $linkType.'.'.$package.' : invalid value, must be a string containing a version constraint';
unset($this->config[$linkType][$package]);