diff --git a/plugins/Oembed/OembedPlugin.php b/plugins/Oembed/OembedPlugin.php index 64e3e8940c..57ff3f467c 100644 --- a/plugins/Oembed/OembedPlugin.php +++ b/plugins/Oembed/OembedPlugin.php @@ -389,6 +389,13 @@ class OembedPlugin extends Plugin // First see if it's too large for us common_debug(__METHOD__ . ': '.sprintf('Performing HEAD request for remote file id==%u to avoid unnecessarily downloading too large files. URL: %s', $thumbnail->getFileId(), $remoteUrl)); $head = $http->head($remoteUrl); + if (!$head->isOk()) { + common_log(LOG_WARN, 'HEAD request returned HTTP failure, so we will abort now and delete the thumbnail object.'); + $thumbnail->delete(); + return false; + } else { + common_debug('HEAD request returned HTTP success, so we will continue.'); + } $remoteUrl = $head->getEffectiveUrl(); // to avoid going through redirects again $headers = $head->getHeader();