Changeset View
Changeset View
Standalone View
Standalone View
src/aphront/AphrontRequest.php
Show First 20 Lines • Show All 60 Lines • ▼ Show 20 Lines | final class AphrontRequest extends Phobject { | ||||
* @return null|pair<int, int> Null, or beginning and end of the range. | * @return null|pair<int, int> Null, or beginning and end of the range. | ||||
*/ | */ | ||||
public function getURILineRange($key, $limit) { | public function getURILineRange($key, $limit) { | ||||
$range = $this->getURIData($key); | $range = $this->getURIData($key); | ||||
return self::parseURILineRange($range, $limit); | return self::parseURILineRange($range, $limit); | ||||
} | } | ||||
public static function parseURILineRange($range, $limit) { | public static function parseURILineRange($range, $limit) { | ||||
if (!strlen($range)) { | if (!phutil_nonempty_string($range)) { | ||||
return null; | return null; | ||||
} | } | ||||
$range = explode('-', $range, 2); | $range = explode('-', $range, 2); | ||||
foreach ($range as $key => $value) { | foreach ($range as $key => $value) { | ||||
$value = (int)$value; | $value = (int)$value; | ||||
if (!$value) { | if (!$value) { | ||||
▲ Show 20 Lines • Show All 151 Lines • ▼ Show 20 Lines | /* -( Accessing Request Data )--------------------------------------------- */ | ||||
*/ | */ | ||||
public function getJSONMap($name, $default = array()) { | public function getJSONMap($name, $default = array()) { | ||||
if (!isset($this->requestData[$name])) { | if (!isset($this->requestData[$name])) { | ||||
return $default; | return $default; | ||||
} | } | ||||
$raw_data = phutil_string_cast($this->requestData[$name]); | $raw_data = phutil_string_cast($this->requestData[$name]); | ||||
$raw_data = trim($raw_data); | $raw_data = trim($raw_data); | ||||
if (!strlen($raw_data)) { | if (!phutil_nonempty_string($raw_data)) { | ||||
return $default; | return $default; | ||||
} | } | ||||
if ($raw_data[0] !== '{') { | if ($raw_data[0] !== '{') { | ||||
throw new Exception( | throw new Exception( | ||||
pht( | pht( | ||||
'Request parameter "%s" is not formatted properly. Expected a '. | 'Request parameter "%s" is not formatted properly. Expected a '. | ||||
'JSON object, but value does not start with "{".', | 'JSON object, but value does not start with "{".', | ||||
▲ Show 20 Lines • Show All 248 Lines • ▼ Show 20 Lines | private function getCookieDomainURI() { | ||||
} | } | ||||
$host = $this->getHost(); | $host = $this->getHost(); | ||||
// If there's no base domain configured, just use whatever the request | // If there's no base domain configured, just use whatever the request | ||||
// domain is. This makes setup easier, and we'll tell administrators to | // domain is. This makes setup easier, and we'll tell administrators to | ||||
// configure a base domain during the setup process. | // configure a base domain during the setup process. | ||||
$base_uri = PhabricatorEnv::getEnvConfig('phabricator.base-uri'); | $base_uri = PhabricatorEnv::getEnvConfig('phabricator.base-uri'); | ||||
if (!strlen($base_uri)) { | if (!phutil_nonempty_string($base_uri)) { | ||||
return new PhutilURI('http://'.$host.'/'); | return new PhutilURI('http://'.$host.'/'); | ||||
} | } | ||||
$alternates = PhabricatorEnv::getEnvConfig('phabricator.allowed-uris'); | $alternates = PhabricatorEnv::getEnvConfig('phabricator.allowed-uris'); | ||||
$allowed_uris = array_merge( | $allowed_uris = array_merge( | ||||
array($base_uri), | array($base_uri), | ||||
$alternates); | $alternates); | ||||
▲ Show 20 Lines • Show All 440 Lines • ▼ Show 20 Lines | public function newClusterProxyFuture($uri) { | ||||
return $future; | return $future; | ||||
} | } | ||||
public function updateEphemeralCookies() { | public function updateEphemeralCookies() { | ||||
$submit_cookie = PhabricatorCookies::COOKIE_SUBMIT; | $submit_cookie = PhabricatorCookies::COOKIE_SUBMIT; | ||||
$submit_key = $this->getCookie($submit_cookie); | $submit_key = $this->getCookie($submit_cookie); | ||||
if (strlen($submit_key)) { | if (phutil_nonempty_string($submit_key)) { | ||||
$this->clearCookie($submit_cookie); | $this->clearCookie($submit_cookie); | ||||
$this->submitKey = $submit_key; | $this->submitKey = $submit_key; | ||||
} | } | ||||
} | } | ||||
public function getSubmitKey() { | public function getSubmitKey() { | ||||
return $this->submitKey; | return $this->submitKey; | ||||
} | } | ||||
} | } |
Content licensed under Creative Commons Attribution-ShareAlike 4.0 (CC-BY-SA) unless otherwise noted; code licensed under Apache 2.0 or other open source licenses. · CC BY-SA 4.0 · Apache 2.0