瀏覽代碼

Update MediaStorageService, improve head checks to fix failed jobs

Daniel Supernault 4 年之前
父節點
當前提交
1769cdfd74
共有 1 個文件被更改,包括 11 次插入0 次删除
  1. 11 0
      app/Services/MediaStorageService.php

+ 11 - 0
app/Services/MediaStorageService.php

@@ -40,7 +40,18 @@ class MediaStorageService {
 		} catch (RequestException $e) {
 		} catch (RequestException $e) {
 			return false;
 			return false;
 		}
 		}
+
 		$h = $r->getHeaders();
 		$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('pixelfed.max_photo_size') * 1000)
+		) {
+			return false;
+		}
+
 		return [
 		return [
 			'length' => $h['Content-Length'][0],
 			'length' => $h['Content-Length'][0],
 			'mime' => $h['Content-Type'][0]
 			'mime' => $h['Content-Type'][0]