From 25f623565aff0783da5515cf686bdf22246a203b Mon Sep 17 00:00:00 2001 From: Mikael Nordfeldth Date: Sun, 7 Feb 2016 01:54:37 +0100 Subject: [PATCH] Catch http exception in StoreRemoteMedia --- plugins/StoreRemoteMedia/StoreRemoteMediaPlugin.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/plugins/StoreRemoteMedia/StoreRemoteMediaPlugin.php b/plugins/StoreRemoteMedia/StoreRemoteMediaPlugin.php index 34846748e7..a08ae92572 100644 --- a/plugins/StoreRemoteMedia/StoreRemoteMediaPlugin.php +++ b/plugins/StoreRemoteMedia/StoreRemoteMediaPlugin.php @@ -77,8 +77,13 @@ class StoreRemoteMediaPlugin extends Plugin $this->checkWhitelist($file->getUrl()); // First we download the file to memory and test whether it's actually an image file - $imgData = HTTPClient::quickGet($file->getUrl()); - common_debug(sprintf('Downloading remote file id==%u with URL: %s', $file->id, $file->getUrl())); + common_debug(sprintf('Downloading remote file id==%u with URL: %s', $file->getID(), _ve($file->getUrl()))); + try { + $imgData = HTTPClient::quickGet($file->getUrl()); + } catch (HTTP_Request2_ConnectionException $e) { + common_log(LOG_ERR, __CLASS__.': quickGet on URL: '._ve($file->getUrl()).' threw exception: '.$e->getMessage()); + return true; + } $info = @getimagesizefromstring($imgData); if ($info === false) { throw new UnsupportedMediaException(_('Remote file format was not identified as an image.'), $file->getUrl());