[Embed] Fixed bug where sometimes images were written outside the site root

This commit is contained in:
Miguel Dantas 2019-07-14 23:56:31 +01:00 committed by Diogo Cordeiro
parent a244f3ba4d
commit d66828c2bf

View File

@ -451,6 +451,7 @@ class EmbedPlugin extends Plugin
} }
$head = (new HTTPClient())->head($url); $head = (new HTTPClient())->head($url);
$headers = $head->getHeader(); $headers = $head->getHeader();
$headers = array_change_key_case($headers, CASE_LOWER);
} }
return $headers['content-length'] ?: false; return $headers['content-length'] ?: false;
} catch (Exception $err) { } catch (Exception $err) {
@ -475,6 +476,7 @@ class EmbedPlugin extends Plugin
} }
$head = (new HTTPClient())->head($url); $head = (new HTTPClient())->head($url);
$headers = $head->getHeader(); $headers = $head->getHeader();
$headers = array_change_key_case($headers, CASE_LOWER);
} }
return !empty($headers['content-type']) && common_get_mime_media($headers['content-type']) === 'image'; return !empty($headers['content-type']) && common_get_mime_media($headers['content-type']) === 'image';
} }
@ -498,6 +500,7 @@ class EmbedPlugin extends Plugin
$head = (new HTTPClient())->head($url); $head = (new HTTPClient())->head($url);
$headers = $head->getHeader(); $headers = $head->getHeader();
$headers = array_change_key_case($headers, CASE_LOWER);
try { try {
$isImage = $this->isRemoteImage($url, $headers); $isImage = $this->isRemoteImage($url, $headers);