Optimized special character handling in OOF plugin product names (fixes #2848, references #2740)

This commit is contained in:
Bernd Bestel 2026-01-13 20:51:25 +01:00
parent b1e3ef7881
commit bf96ff5b92
No known key found for this signature in database
GPG Key ID: 71BD34C0D4891300
2 changed files with 2 additions and 5 deletions

View File

@ -14,7 +14,7 @@
- External barcode lookup plugin optimizations: - 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) - 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) - 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 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) - 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)

View File

@ -22,7 +22,7 @@ class OpenFoodFactsBarcodeLookupPlugin extends BaseBarcodeLookupPlugin
// Guzzle throws exceptions for connection errors, so nothing to do on that here // 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) if ($statusCode == 404 || $data->status != 1)
{ {
// Nothing found for the given barcode // Nothing found for the given barcode
@ -57,9 +57,6 @@ class OpenFoodFactsBarcodeLookupPlugin extends BaseBarcodeLookupPlugin
$name = $data->product->$productNameFieldLocalized; $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 [ return [
'name' => $name, 'name' => $name,
'location_id' => $locationId, 'location_id' => $locationId,