don't crash when the default in .define is not initialized on .call
authorTony Cook <tony@develop-help.com>
Thu, 20 Mar 2014 03:31:57 +0000 (14:31 +1100)
committerTony Cook <tony@develop-help.com>
Sat, 9 May 2015 04:06:40 +0000 (14:06 +1000)
site/cgi-bin/modules/Squirrel/Template/Processor.pm

index 30de50b..0d921ff 100644 (file)
@@ -171,6 +171,12 @@ sub _process_define {
   return;
 }
 
+sub _expr_died {
+  my ($self, $node, $die, $ctx) = @_;
+
+  return $node->[NODE_ORIG];
+}
+
 sub _process_call {
   my ($self, $node) = @_;
 
@@ -205,7 +211,9 @@ sub _process_call {
          my ($name_expr, $value_expr)= @$entry;
          my $name = $self->[EVAL]->process($name_expr);
          unless (exists $args{$name}) {
-           my $value = $self->[EVAL]->process($value_expr);
+           my $value;
+           eval { $value = $self->[EVAL]->process($value_expr); 1 }
+             or return $self->_expr_died($node, $@, $ctx . " value for $name");
            $self->[TMPLT]->set_var($name, $value);
          }
        }