Update MediaStorageService, improve header parsing

pull/3035/head
Daniel Supernault 2021-12-04 17:30:05 -07:00
rodzic 2aa73c1ffa
commit 9d9e9ce7fa
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 0DEF1C662C9033F7
1 zmienionych plików z 14 dodań i 8 usunięć

Wyświetl plik

@ -43,18 +43,24 @@ class MediaStorageService {
$h = $r->getHeaders();
if (isset($h['Content-Length'], $h['Content-Type']) == false ||
empty($h['Content-Length']) ||
empty($h['Content-Type']) ||
$h['Content-Length'] < 10 ||
$h['Content-Length'] > (config_cache('pixelfed.max_photo_size') * 1000)
) {
if (isset($h['Content-Length'], $h['Content-Type']) == false) {
return false;
}
if(empty($h['Content-Length']) || empty($h['Content-Type']) ) {
return false;
}
$len = is_array($h['Content-Length']) ? $h['Content-Length'][0] : $h['Content-Length'];
$mime = is_array($h['Content-Type']) ? $h['Content-Type'][0] : $h['Content-Type'];
if($len < 10 || $len > ((config_cache('pixelfed.max_photo_size') * 1000))) {
return false;
}
return [
'length' => $h['Content-Length'][0],
'mime' => $h['Content-Type'][0]
'length' => $len,
'mime' => $mime
];
}