Skip to content

Commit

Permalink
handle " escapes in ingredients, bug #1776
Browse files Browse the repository at this point in the history
  • Loading branch information
root committed May 17, 2019
1 parent 8a835a8 commit ef22aea
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/ProductOpener/Ingredients.pm
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,7 @@ sub extract_ingredients_from_text($) {
return if not defined $product_ref->{ingredients_text};

my $text = $product_ref->{ingredients_text};
$text =~ s/\"/"/g;

$log->debug("extracting ingredients from text", { text => $text }) if $log->is_debug();

Expand Down Expand Up @@ -549,11 +550,11 @@ sub extract_ingredients_from_text($) {
$origin =~ s/\s+$//;
}

if ($ingredient =~ /\b(bio|organic|halal)\b/i) {
if ($ingredient =~ /\b(bio|biologique|biologico|organic|halal)\b/i) {
$label = $1;
$label =~ s/^\s+//;
$label =~ s/\s+$//;
$ingredient =~ s/\b(bio|organic|halal)\b//i;
$ingredient =~ s/\b(bio|biologique|biologico|organic|halal)\b//i;
$ingredient =~ s/\s+/ /g;
}

Expand Down Expand Up @@ -903,6 +904,8 @@ sub extract_ingredients_classes_from_text($) {
my $path = product_path($product_ref->{code});
my $text = $product_ref->{ingredients_text};
my $lc = $product_ref->{lc};

$text =~ s/\"/"/g;

# vitamins...
# vitamines A, B1, B2, B5, B6, B9, B12, C, D, H, PP et E (lactose, protéines de lait)
Expand Down Expand Up @@ -1822,6 +1825,7 @@ sub detect_allergens_from_text($) {
foreach my $language (keys %{$product_ref->{languages_codes}}) {

my $text = $product_ref->{"ingredients_text_" . $language };
$text =~ s/\"/"/g;

next if not defined $text;

Expand Down

0 comments on commit ef22aea

Please sign in to comment.