diff --git a/changelog/81_UNRELEASED_xxxx-xx-xx.md b/changelog/81_UNRELEASED_xxxx-xx-xx.md index 41ed0019..739d2aed 100644 --- a/changelog/81_UNRELEASED_xxxx-xx-xx.md +++ b/changelog/81_UNRELEASED_xxxx-xx-xx.md @@ -14,7 +14,7 @@ - External barcode lookup plugin optimizations: - When an image URL without a file extension is returned, the file extension is now determined by the Content-Type header (if any) (thanks @jordy-u for the idea) - Data URLs for images are now supported (`data:image/png;base64,xxxx`) (thanks @GammaC0de) -- Fixed that German Umlauts were removed from product names when looking up a barcode via the built-in Open Food Facts external barcode lookup plugin +- Fixed that German Umlauts and other special characters were removed from product names when looking up a barcode via the built-in Open Food Facts external barcode lookup plugin - Fixed that when using/scanning a barcode on the purchase page with a note attached (which prefills the note field) and when manually selecting another product afterwards, the note of the previously used barcode was incorrectly prefilled again - Fixed that the "next input focus handling" (jumping to the next input after entering a value) didn't work at some places (e.g. after entering a purchased date on the purchase page) diff --git a/plugins/OpenFoodFactsBarcodeLookupPlugin.php b/plugins/OpenFoodFactsBarcodeLookupPlugin.php index 6225d3e7..749490d5 100644 --- a/plugins/OpenFoodFactsBarcodeLookupPlugin.php +++ b/plugins/OpenFoodFactsBarcodeLookupPlugin.php @@ -22,7 +22,7 @@ class OpenFoodFactsBarcodeLookupPlugin extends BaseBarcodeLookupPlugin // Guzzle throws exceptions for connection errors, so nothing to do on that here - $data = json_decode($response->getBody()); + $data = json_decode(mb_convert_encoding($response->getBody(), 'UTF-8', 'UTF-8')); if ($statusCode == 404 || $data->status != 1) { // Nothing found for the given barcode @@ -57,9 +57,6 @@ class OpenFoodFactsBarcodeLookupPlugin extends BaseBarcodeLookupPlugin $name = $data->product->$productNameFieldLocalized; } - // Remove non-ASCII characters in product name (whyever a product name should have them at all) - $name = preg_replace('/[^a-zA-Z0-9äöüÄÖÜß ]/', '', $name); - return [ 'name' => $name, 'location_id' => $locationId,