mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-25 15:55:22 +00:00
Update MediaStorageService, improve header parsing
This commit is contained in:
parent
2aa73c1ffa
commit
9d9e9ce7fa
1 changed files with 14 additions and 8 deletions
|
@ -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
|
||||
];
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue