Changeset View
Changeset View
Standalone View
Standalone View
src/infrastructure/env/PhabricatorEnv.php
| Show First 20 Lines • Show All 400 Lines • ▼ Show 20 Lines | public static function getProductionURI($path) { | ||||
| $production_domain = self::getEnvConfig('phabricator.production-uri'); | $production_domain = self::getEnvConfig('phabricator.production-uri'); | ||||
| if (!$production_domain) { | if (!$production_domain) { | ||||
| $production_domain = self::getAnyBaseURI(); | $production_domain = self::getAnyBaseURI(); | ||||
| } | } | ||||
| return rtrim($production_domain, '/').$path; | return rtrim($production_domain, '/').$path; | ||||
| } | } | ||||
| public static function getAllowedURIs($path) { | |||||
| $uri = new PhutilURI($path); | public static function isSelfURI($raw_uri) { | ||||
| if ($uri->getDomain()) { | $uri = new PhutilURI($raw_uri); | ||||
| return $path; | |||||
| $host = $uri->getDomain(); | |||||
| if (!strlen($host)) { | |||||
| return false; | |||||
| } | } | ||||
| $host = phutil_utf8_strtolower($host); | |||||
| $self_map = self::getSelfURIMap(); | |||||
| return isset($self_map[$host]); | |||||
| } | |||||
| private static function getSelfURIMap() { | |||||
| $self_uris = array(); | |||||
| $self_uris[] = self::getProductionURI('/'); | |||||
| $self_uris[] = self::getURI('/'); | |||||
| $allowed_uris = self::getEnvConfig('phabricator.allowed-uris'); | $allowed_uris = self::getEnvConfig('phabricator.allowed-uris'); | ||||
| $return = array(); | |||||
| foreach ($allowed_uris as $allowed_uri) { | foreach ($allowed_uris as $allowed_uri) { | ||||
| $return[] = rtrim($allowed_uri, '/').$path; | $self_uris[] = $allowed_uri; | ||||
| } | } | ||||
| return $return; | $self_map = array(); | ||||
| foreach ($self_uris as $self_uri) { | |||||
| $host = id(new PhutilURI($self_uri))->getDomain(); | |||||
| if (!strlen($host)) { | |||||
| continue; | |||||
| } | } | ||||
| $host = phutil_utf8_strtolower($host); | |||||
| $self_map[$host] = $host; | |||||
| } | |||||
| return $self_map; | |||||
| } | |||||
| /** | /** | ||||
| * Get the fully-qualified production URI for a static resource path. | * Get the fully-qualified production URI for a static resource path. | ||||
| * | * | ||||
| * @task read | * @task read | ||||
| */ | */ | ||||
| public static function getCDNURI($path) { | public static function getCDNURI($path) { | ||||
| $alt = self::getEnvConfig('security.alternate-file-domain'); | $alt = self::getEnvConfig('security.alternate-file-domain'); | ||||
| ▲ Show 20 Lines • Show All 509 Lines • Show Last 20 Lines | |||||