Browse Source

Update MediaStorageService, improve head checks to fix failed jobs

Daniel Supernault 4 years ago
parent
commit
1769cdfd74
1 changed files with 11 additions and 0 deletions
  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]