Changeset View
Changeset View
Standalone View
Standalone View
src/applications/diffusion/request/DiffusionRequest.php
Show First 20 Lines • Show All 201 Lines • ▼ Show 20 Lines | /* -( Creating Requests )-------------------------------------------------- */ | ||||
* Internal. Use @{method:newFromDictionary}, not this method. | * Internal. Use @{method:newFromDictionary}, not this method. | ||||
* | * | ||||
* @param map Map of parsed data. | * @param map Map of parsed data. | ||||
* @return void | * @return void | ||||
* @task new | * @task new | ||||
*/ | */ | ||||
private function initializeFromDictionary(array $data) { | private function initializeFromDictionary(array $data) { | ||||
$blob = idx($data, 'blob'); | $blob = idx($data, 'blob'); | ||||
if (strlen($blob)) { | if (phutil_nonempty_string($blob)) { | ||||
$blob = self::parseRequestBlob($blob, $this->supportsBranches()); | $blob = self::parseRequestBlob($blob, $this->supportsBranches()); | ||||
$data = $blob + $data; | $data = $blob + $data; | ||||
} | } | ||||
$this->path = idx($data, 'path'); | $this->path = idx($data, 'path'); | ||||
$this->line = idx($data, 'line'); | $this->line = idx($data, 'line'); | ||||
$this->initFromConduit = idx($data, 'initFromConduit', true); | $this->initFromConduit = idx($data, 'initFromConduit', true); | ||||
$this->lint = idx($data, 'lint'); | $this->lint = idx($data, 'lint'); | ||||
▲ Show 20 Lines • Show All 294 Lines • ▼ Show 20 Lines | public static function parseRequestBlob($blob, $supports_branches) { | ||||
// We've consumed the commit if it exists, so unescape ";" in the rest | // We've consumed the commit if it exists, so unescape ";" in the rest | ||||
// of the string. | // of the string. | ||||
$blob = str_replace(';;', ';', $blob); | $blob = str_replace(';;', ';', $blob); | ||||
if (strlen($blob)) { | if (strlen($blob)) { | ||||
$result['path'] = $blob; | $result['path'] = $blob; | ||||
} | } | ||||
if ($result['path'] !== null) { | |||||
$parts = explode('/', $result['path']); | $parts = explode('/', $result['path']); | ||||
foreach ($parts as $part) { | foreach ($parts as $part) { | ||||
// Prevent any hyjinx since we're ultimately shipping this to the | // Prevent any hyjinx since we're ultimately shipping this to the | ||||
// filesystem under a lot of workflows. | // filesystem under a lot of workflows. | ||||
if ($part == '..') { | if ($part == '..') { | ||||
throw new Exception(pht('Invalid path URI.')); | throw new Exception(pht('Invalid path URI.')); | ||||
} | } | ||||
} | } | ||||
} | |||||
return $result; | return $result; | ||||
} | } | ||||
/** | /** | ||||
* Check that the working copy of the repository is present and readable. | * Check that the working copy of the repository is present and readable. | ||||
* | * | ||||
* @param string Path to the working copy. | * @param string Path to the working copy. | ||||
▲ Show 20 Lines • Show All 162 Lines • Show Last 20 Lines |