Changeset View
Changeset View
Standalone View
Standalone View
src/applications/files/storage/PhabricatorFile.php
| Show First 20 Lines • Show All 446 Lines • ▼ Show 20 Lines | if (!$engine_identifier || strlen($engine_identifier) > 32) { | ||||
| "and no longer than 32 characters."); | "and no longer than 32 characters."); | ||||
| } | } | ||||
| return array($engine_identifier, $data_handle); | return array($engine_identifier, $data_handle); | ||||
| } | } | ||||
| public static function newFromFileDownload($uri, array $params = array()) { | public static function newFromFileDownload($uri, array $params = array()) { | ||||
| // Make sure we're allowed to make a request first | PhabricatorEnv::requireValidRemoteURIForFetch( | ||||
| if (!PhabricatorEnv::getEnvConfig('security.allow-outbound-http')) { | $uri, | ||||
| throw new Exception('Outbound HTTP requests are disabled!'); | array( | ||||
| } | 'http', | ||||
| 'https', | |||||
| $uri = new PhutilURI($uri); | )); | ||||
| $protocol = $uri->getProtocol(); | |||||
| switch ($protocol) { | |||||
| case 'http': | |||||
| case 'https': | |||||
| break; | |||||
| default: | |||||
| // Make sure we are not accessing any file:// URIs or similar. | |||||
| return null; | |||||
| } | |||||
| $timeout = 5; | $timeout = 5; | ||||
| list($file_data) = id(new HTTPSFuture($uri)) | list($file_data) = id(new HTTPSFuture($uri)) | ||||
| ->setTimeout($timeout) | ->setTimeout($timeout) | ||||
| ->resolvex(); | ->resolvex(); | ||||
| $params = $params + array( | $params = $params + array( | ||||
| 'name' => basename($uri), | 'name' => basename($uri), | ||||
| ); | ); | ||||
| ▲ Show 20 Lines • Show All 831 Lines • Show Last 20 Lines | |||||