FIX: Issue with __image_url when it contains HTTP params (ie, ?<params>)

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.
This commit is contained in:
João Cabral 2025-03-04 17:21:24 +00:00
parent 63dcfcde47
commit 95a8a4a24d
No known key found for this signature in database

View File

@ -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;
}