mirror of
https://github.com/grocy/grocy.git
synced 2025-08-20 12:20:22 +00:00
Optimize product name special characters handling in OFF external barcode lookup plugin
This commit is contained in:
59
changelog/80_UNRELEASED_xxxx-xx-xx.md
Normal file
59
changelog/80_UNRELEASED_xxxx-xx-xx.md
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
> ⚠️ xxxBREAKING CHANGESxxx
|
||||||
|
|
||||||
|
> ❗ xxxImportant upgrade informationXXX
|
||||||
|
|
||||||
|
> 💡 xxxMinor upgrade informationXXX
|
||||||
|
|
||||||
|
### New Feature: xxxx
|
||||||
|
|
||||||
|
- xxx
|
||||||
|
|
||||||
|
### Stock
|
||||||
|
|
||||||
|
- Optimizations in the built-in Open Food Facts external barcode lookup plugin:
|
||||||
|
- A provided but empty localized product name is now ignored
|
||||||
|
- Non-ASCII characters in product names are now ignored (e.g. line breaks caused problems)
|
||||||
|
|
||||||
|
### Shopping list
|
||||||
|
|
||||||
|
- xxx
|
||||||
|
|
||||||
|
### Recipes
|
||||||
|
|
||||||
|
- xxx
|
||||||
|
|
||||||
|
### Meal plan
|
||||||
|
|
||||||
|
- xxx
|
||||||
|
|
||||||
|
### Chores
|
||||||
|
|
||||||
|
- xxx
|
||||||
|
|
||||||
|
### Calendar
|
||||||
|
|
||||||
|
- xxx
|
||||||
|
|
||||||
|
### Tasks
|
||||||
|
|
||||||
|
- xxx
|
||||||
|
|
||||||
|
### Batteries
|
||||||
|
|
||||||
|
- xxx
|
||||||
|
|
||||||
|
### Equipment
|
||||||
|
|
||||||
|
- xxx
|
||||||
|
|
||||||
|
### Userfields
|
||||||
|
|
||||||
|
- xxx
|
||||||
|
|
||||||
|
### General
|
||||||
|
|
||||||
|
- xxx
|
||||||
|
|
||||||
|
### API
|
||||||
|
|
||||||
|
- xxx
|
@@ -52,11 +52,14 @@ class OpenFoodFactsBarcodeLookupPlugin extends BaseBarcodeLookupPlugin
|
|||||||
|
|
||||||
// Use the localized product name, if provided
|
// Use the localized product name, if provided
|
||||||
$name = $data->product->product_name;
|
$name = $data->product->product_name;
|
||||||
if (isset($data->product->$productNameFieldLocalized))
|
if (isset($data->product->$productNameFieldLocalized) && !empty($data->product->$productNameFieldLocalized))
|
||||||
{
|
{
|
||||||
$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('/[^\x20-\x7E]/', '', $name);
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'name' => $name,
|
'name' => $name,
|
||||||
'location_id' => $locationId,
|
'location_id' => $locationId,
|
||||||
|
Reference in New Issue
Block a user