1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-18 12:52:42 +01:00

Fix production file links for some alt-domain configurations

Summary:
We sometimes call PhabricatorEnv::getProductionURI($file->getBestURI()) or
similar, but this may currently cause us to construct a URI like this:

  http://domain.com/http://cdn-domain.com/file/data/xxx/yyy/name.jpg

Instead, if the provided URI has a domain already, leave it unmodified.

Test Plan: Attached a file to a task; got an email with a valid URI instead of
an invalid URI.

Reviewers: btrahan

Reviewed By: btrahan

CC: Makinde, aran, epriestley

Differential Revision: https://secure.phabricator.com/D1622
This commit is contained in:
epriestley 2012-02-15 17:06:36 -08:00
parent 4bd336cedc
commit fce6a7089c

View file

@ -39,11 +39,19 @@ final class PhabricatorEnv {
}
public static function getProductionURI($path) {
$uri = self::getEnvConfig('phabricator.production-uri');
if (!$uri) {
$uri = self::getEnvConfig('phabricator.base-uri');
// If we're passed a URI which already has a domain, simply return it
// unmodified. In particular, files may have URIs which point to a CDN
// domain.
$uri = new PhutilURI($path);
if ($uri->getDomain()) {
return $path;
}
return rtrim($uri, '/').$path;
$production_domain = self::getEnvConfig('phabricator.production-uri');
if (!$production_domain) {
$production_domain = self::getEnvConfig('phabricator.base-uri');
}
return rtrim($production_domain, '/').$path;
}
public static function getCDNURI($path) {