From 8b9217737ad79304a8be14a6ec431c7212472884 Mon Sep 17 00:00:00 2001 From: "b.stepanenko" Date: Mon, 12 Apr 2021 13:38:27 +0300 Subject: [PATCH 1/2] Avoid no-url index in stream_get_meta_data --- src/Utils.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Utils.php b/src/Utils.php index f4e48640..e2f40400 100644 --- a/src/Utils.php +++ b/src/Utils.php @@ -317,7 +317,8 @@ public static function streamFor($resource = '', array $options = []) * The 'php://input' is a special stream with quirks and inconsistencies. * We avoid using that stream by reading it into php://temp */ - if (\stream_get_meta_data($resource)['uri'] === 'php://input') { + $metaData = \stream_get_meta_data($resource); + if (array_key_exists('uri', $metaData) && $metaData['uri'] === 'php://input') { $stream = self::tryFopen('php://temp', 'w+'); fwrite($stream, stream_get_contents($resource)); fseek($stream, 0); From 9cc30ad67734275ce38fe67294b969864ec03d46 Mon Sep 17 00:00:00 2001 From: "b.stepanenko" Date: Mon, 12 Apr 2021 13:53:06 +0300 Subject: [PATCH 2/2] isset instead of check key is exists --- src/Utils.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Utils.php b/src/Utils.php index e2f40400..6b6c8cce 100644 --- a/src/Utils.php +++ b/src/Utils.php @@ -318,7 +318,7 @@ public static function streamFor($resource = '', array $options = []) * We avoid using that stream by reading it into php://temp */ $metaData = \stream_get_meta_data($resource); - if (array_key_exists('uri', $metaData) && $metaData['uri'] === 'php://input') { + if (isset($metaData['uri']) && $metaData['uri'] === 'php://input') { $stream = self::tryFopen('php://temp', 'w+'); fwrite($stream, stream_get_contents($resource)); fseek($stream, 0);