Bug #22243 » 4-4-alpha2_0013750.patch
class.t3lib_div.php (working copy) | ||
---|---|---|
* @param boolean If set, the elements of the resulting array are unquoted.
|
||
* @return array Exploded parameters
|
||
*/
|
||
public static function unQuoteFilenames($parameters,$unQuote=FALSE) {
|
||
$paramsArr = explode(' ', trim($parameters));
|
||
public static function unQuoteFilenames($parameters, $unQuote = FALSE) {
|
||
// Replace spaces inside an quoted argument with a placeholder
|
||
$parameters = preg_replace('/("|\')([\w\:\/\.]+)\s+([\w\:\/\.]+)("|\')/', "$1$2###SPACETMP###$3$4", $parameters);
|
||
$sourceArray = explode(' ', trim($parameters));
|
||
$targetArray = array();
|
||
$quoteActive = -1; // Whenever a quote character (") is found, $quoteActive is set to the element number inside of $params. A value of -1 means that there are not open quotes at the current position.
|
||
foreach ($paramsArr as $k => $v) {
|
||
if($quoteActive > -1) {
|
||
$paramsArr[$quoteActive] .= ' '.$v;
|
||
unset($paramsArr[$k]);
|
||
if(preg_match('/"$/', $v)) { $quoteActive = -1; }
|
||
} elseif(!trim($v)) {
|
||
unset($paramsArr[$k]); // Remove empty elements
|
||
} elseif(preg_match('/^"/', $v)) {
|
||
$quoteActive = $k;
|
||
foreach ($sourceArray as $value) {
|
||
$value = trim($value);
|
||
if ($value !== '') {
|
||
if ($unQuote) {
|
||
$value = preg_replace('/(^"|"$|^\'|\'$)/','',$value);
|
||
$value = str_replace(array('"[', '\'['), '[', $value);
|
||
}
|
||
array_push($targetArray, str_replace('###SPACETMP###', ' ', $value));
|
||
}
|
||
}
|
||
if($unQuote) {
|
||
foreach ($paramsArr as $key => &$val) {
|
||
$val = preg_replace('/(^"|"$)/','',$val);
|
||
}
|
||
}
|
||
// return reindexed array
|
||
return array_values($paramsArr);
|
||
return $targetArray;
|
||
}
|
||