From 95a8a4a24dc04a0d99648f9757b4b1340b21fce0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Cabral?= Date: Tue, 4 Mar 2025 17:21:24 +0000 Subject: [PATCH] FIX: Issue with __image_url when it contains HTTP params (ie, ?) This commit make sure Grocy only uses the base URL when creating the filename for the product image from the __image_url. When the __image_url contains HTTP parms it will split the URL on the '?' character and only use the 1st part. --- services/StockService.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/StockService.php b/services/StockService.php index 2261db4e..77178951 100644 --- a/services/StockService.php +++ b/services/StockService.php @@ -626,7 +626,7 @@ class StockService extends BaseService { $webClient = new Client(); $response = $webClient->request('GET', $pluginOutput['__image_url'], ['headers' => ['User-Agent' => 'Grocy/' . $this->getApplicationService()->GetInstalledVersion()->Version . ' (https://grocy.info)']]); - $fileName = $pluginOutput['__barcode'] . '.' . pathinfo($pluginOutput['__image_url'], PATHINFO_EXTENSION); + $fileName = $pluginOutput['__barcode'] . '.' . pathinfo(explode('?', $pluginOutput['__image_url'])[0], PATHINFO_EXTENSION); file_put_contents($this->getFilesService()->GetFilePath('productpictures', $fileName), $response->getBody()); $productData['picture_file_name'] = $fileName; }