From f5987f9612b923c4d64d0456c837c075096803a0 Mon Sep 17 00:00:00 2001 From: Chris Date: Sat, 13 Jul 2024 13:52:46 +0100 Subject: [PATCH] Allow apostrophe in ingredient and separator names --- blocks/ORB/Common.pm | 3 +++ modules/ORB.pm | 4 ++-- templates/default/clone/content.tem | 4 ++-- templates/default/edit/content.tem | 4 ++-- templates/default/new/content.tem | 4 ++-- templates/default/new/ingredient.tem | 2 +- templates/default/new/separator.tem | 2 +- 7 files changed, 13 insertions(+), 10 deletions(-) diff --git a/blocks/ORB/Common.pm b/blocks/ORB/Common.pm index b83d606..1c3ac2d 100644 --- a/blocks/ORB/Common.pm +++ b/blocks/ORB/Common.pm @@ -24,6 +24,7 @@ use parent qw(ORB); # This class extends the ORB block class use experimental qw(smartmatch); use v5.14; use JSON; +use Data::Dumper; # How many ingredient rows should appear in the empty form? use constant DEFAULT_INGREDIENT_COUNT => 5; @@ -347,6 +348,8 @@ sub _validate_ingredients { return $self -> {"template"} -> load_template("error/error_item.tem", { "%(error)s" => "{L_ERR_JSONFORMAT}: $@" }) if($@); + print STDERR "Got ingdata ".Dumper($ingdata); + foreach my $ingred (@{$ingdata -> {"ingredients"}}) { if($ingred -> {"separator"}) { $errors .= $self -> _validate_separator($args, $ingred); diff --git a/modules/ORB.pm b/modules/ORB.pm index 97c16c0..9904b45 100755 --- a/modules/ORB.pm +++ b/modules/ORB.pm @@ -77,8 +77,8 @@ sub new { "recipename" => '^[-\w,.\' ]+$', "tags" => '^[-\w ]+$', "quantity" => '^[\d\w./]+$', - "sepname" => '^[-\w,.:()&;#*\ ]{1,255}$', - "ingredient" => '^[-\w,.:()&;#*\ ]{1,255}$', + "sepname" => '^[-\w,.:()&;#*\ \']{1,255}$', + "ingredient" => '^[-\w,.:()&;#*\ \']{1,255}$', "notes" => '^[-()\w,."!\'\\/£$%;:@#?><* ]{1,255}$', }; diff --git a/templates/default/clone/content.tem b/templates/default/clone/content.tem index 5cead7a..eb2bc04 100644 --- a/templates/default/clone/content.tem +++ b/templates/default/clone/content.tem @@ -126,7 +126,7 @@
- +
@@ -139,7 +139,7 @@
  • - +
    diff --git a/templates/default/edit/content.tem b/templates/default/edit/content.tem index 4139b2b..4247d66 100644 --- a/templates/default/edit/content.tem +++ b/templates/default/edit/content.tem @@ -126,7 +126,7 @@
    - +
    @@ -139,7 +139,7 @@
  • - +
    diff --git a/templates/default/new/content.tem b/templates/default/new/content.tem index 689e1e6..3e929b2 100644 --- a/templates/default/new/content.tem +++ b/templates/default/new/content.tem @@ -126,7 +126,7 @@
    - +
    @@ -139,7 +139,7 @@
  • - +
    diff --git a/templates/default/new/ingredient.tem b/templates/default/new/ingredient.tem index c7db371..356c5f0 100644 --- a/templates/default/new/ingredient.tem +++ b/templates/default/new/ingredient.tem @@ -14,7 +14,7 @@
    - +
    diff --git a/templates/default/new/separator.tem b/templates/default/new/separator.tem index 438ea97..c640271 100644 --- a/templates/default/new/separator.tem +++ b/templates/default/new/separator.tem @@ -1,7 +1,7 @@
  • - +