@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Don't require prototypes for "{image ...}"

Summary: Depends on D19194. Fixes T4190. This should be in good-enough shape now to release and support more generally.

Test Plan: Used `{image ...}` in remarkup.

Maniphest Tasks: T4190

Differential Revision: https://secure.phabricator.com/D19195

+16 -18
+16 -18
src/applications/files/controller/PhabricatorFileImageProxyController.php
··· 8 8 } 9 9 10 10 public function handleRequest(AphrontRequest $request) { 11 - 12 - $show_prototypes = PhabricatorEnv::getEnvConfig( 13 - 'phabricator.show-prototypes'); 14 - if (!$show_prototypes) { 15 - throw new Exception( 16 - pht('Show prototypes is disabled. 17 - Set `phabricator.show-prototypes` to `true` to use the image proxy')); 18 - } 19 - 20 11 $viewer = $request->getViewer(); 21 12 $img_uri = $request->getStr('uri'); 22 13 ··· 24 15 PhabricatorEnv::requireValidRemoteURIForLink($img_uri); 25 16 $uri = new PhutilURI($img_uri); 26 17 $proto = $uri->getProtocol(); 27 - if (!in_array($proto, array('http', 'https'))) { 18 + 19 + $allowed_protocols = array( 20 + 'http', 21 + 'https', 22 + ); 23 + if (!in_array($proto, $allowed_protocols)) { 28 24 throw new Exception( 29 - pht('The provided image URI must be either http or https')); 25 + pht( 26 + 'The provided image URI must use one of these protocols: %s.', 27 + implode(', ', $allowed_protocols))); 30 28 } 31 29 32 30 // Check if we already have the specified image URI downloaded ··· 43 41 ->setURI($img_uri) 44 42 ->setTTL($ttl); 45 43 44 + // Cache missed, so we'll need to validate and download the image. 46 45 $unguarded = AphrontWriteGuard::beginScopedUnguardedWrites(); 47 46 $save_request = false; 48 - // Cache missed so we'll need to validate and download the image 49 47 try { 50 48 // Rate limit outbound fetches to make this mechanism less useful for 51 49 // scanning networks and ports. ··· 60 58 'viewPolicy' => PhabricatorPolicies::POLICY_NOONE, 61 59 'canCDN' => true, 62 60 )); 61 + 63 62 if (!$file->isViewableImage()) { 64 63 $mime_type = $file->getMimeType(); 65 64 $engine = new PhabricatorDestructionEngine(); ··· 67 66 $file = null; 68 67 throw new Exception( 69 68 pht( 70 - 'The URI "%s" does not correspond to a valid image file, got '. 71 - 'a file with MIME type "%s". You must specify the URI of a '. 69 + 'The URI "%s" does not correspond to a valid image file (got '. 70 + 'a file with MIME type "%s"). You must specify the URI of a '. 72 71 'valid image file.', 73 72 $uri, 74 73 $mime_type)); 75 - } else { 76 - $file->save(); 77 74 } 75 + 76 + $file->save(); 78 77 79 78 $external_request 80 79 ->setIsSuccessful(1) ··· 84 83 } catch (HTTPFutureHTTPResponseStatus $status) { 85 84 $external_request 86 85 ->setIsSuccessful(0) 87 - ->setResponseMessage($status->getMessage()) 88 - ->save(); 86 + ->setResponseMessage($status->getMessage()); 89 87 90 88 $save_request = true; 91 89 } catch (Exception $ex) {