[web-downloads] main: Verify artifact mimetype

From: Date: Mon, 12 Aug 2024 01:55:52 +0000
Subject: [web-downloads] main: Verify artifact mimetype
Groups: php.webmaster 
Request: Send a blank email to php-webmaster+get-31938@lists.php.net to get a copy of this message
Author: Shivam Mathur (shivammathur) Date: 2024-08-12T07:25:22+05:30 Commit: https://github.com/php/web-downloads/commit/8c9f6f7520b571633bc33c04e2da33ed7195b237 Raw diff: https://github.com/php/web-downloads/commit/8c9f6f7520b571633bc33c04e2da33ed7195b237.diff Verify artifact mimetype Changed paths: M composer.json M composer.lock M src/PeclHandler.php Diff: diff --git a/composer.json b/composer.json index 13c6367..d5eb926 100644 --- a/composer.json +++ b/composer.json @@ -12,6 +12,7 @@ "php": "^8.2", "vlucas/phpdotenv": "^5.6.1", "ext-curl": "*", - "ext-zip": "*" + "ext-zip": "*", + "ext-fileinfo": "*" } } diff --git a/composer.lock b/composer.lock index 4cd79e8..f354f58 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "2232ff6e8dc2b9f9eef60c1cd337ae70", + "content-hash": "86fdb4a7f08015412baf414833597905", "packages": [ { "name": "graham-campbell/result-type", @@ -476,7 +476,8 @@ "platform": { "php": "^8.2", "ext-curl": "*", - "ext-zip": "*" + "ext-zip": "*", + "ext-fileinfo": "*" }, "platform-dev": [], "plugin-api-version": "2.6.0" diff --git a/src/PeclHandler.php b/src/PeclHandler.php index 125b65f..2cfea4a 100644 --- a/src/PeclHandler.php +++ b/src/PeclHandler.php @@ -47,7 +47,7 @@ private function fetchExtension(string $extension, string $ref, string $url, str FetchArtifact::handle($url, $filepath, $token); - if(!file_exists($filepath)) { + if(!file_exists($filepath) || !mime_content_type($filepath) === 'application/zip') { throw new Exception('Failed to fetch the extension'); }

« previous php.webmaster (#31938) next »