mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-12-23 08:14:10 +00:00
Update MediaStorageService, improve head header handling
This commit is contained in:
parent
4b611be2d9
commit
3590adbd87
1 changed files with 9 additions and 19 deletions
|
@ -16,6 +16,7 @@ use App\Services\AccountService;
|
||||||
use App\Http\Controllers\AvatarController;
|
use App\Http\Controllers\AvatarController;
|
||||||
use GuzzleHttp\Exception\RequestException;
|
use GuzzleHttp\Exception\RequestException;
|
||||||
use App\Jobs\MediaPipeline\MediaDeletePipeline;
|
use App\Jobs\MediaPipeline\MediaDeletePipeline;
|
||||||
|
use Illuminate\Support\Arr;
|
||||||
|
|
||||||
class MediaStorageService {
|
class MediaStorageService {
|
||||||
|
|
||||||
|
@ -42,27 +43,16 @@ class MediaStorageService {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$h = $r->getHeaders();
|
$h = Arr::mapWithKeys($r->getHeaders(), function($item, $key) {
|
||||||
|
return [strtolower($key) => last($item)];
|
||||||
|
});
|
||||||
|
|
||||||
if (isset($h['content-length']) && isset($h['content-type'])) {
|
if(!isset($h['content-length'], $h['content-type'])) {
|
||||||
if(empty($h['content-length']) || empty($h['content-type'])) {
|
return false;
|
||||||
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'];
|
|
||||||
} else {
|
|
||||||
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'];
|
|
||||||
}
|
|
||||||
|
|
||||||
|
$len = (int) $h['content-length'];
|
||||||
|
$mime = $h['content-type'];
|
||||||
|
|
||||||
if($len < 10 || $len > ((config_cache('pixelfed.max_photo_size') * 1000))) {
|
if($len < 10 || $len > ((config_cache('pixelfed.max_photo_size') * 1000))) {
|
||||||
return false;
|
return false;
|
||||||
|
|
Loading…
Reference in a new issue