mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-12-01 10:43:16 +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();
|
$h = $r->getHeaders();
|
||||||
|
|
||||||
if (isset($h['Content-Length'], $h['Content-Type']) == false ||
|
if (isset($h['Content-Length'], $h['Content-Type']) == false) {
|
||||||
empty($h['Content-Length']) ||
|
return false;
|
||||||
empty($h['Content-Type']) ||
|
}
|
||||||
$h['Content-Length'] < 10 ||
|
|
||||||
$h['Content-Length'] > (config_cache('pixelfed.max_photo_size') * 1000)
|
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 false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'length' => $h['Content-Length'][0],
|
'length' => $len,
|
||||||
'mime' => $h['Content-Type'][0]
|
'mime' => $mime
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue