You are here: Foswiki>Tasks Web>Item14741 (28 Mar 2022, MichaelDaum)Edit Attach

Item14741: EVAL(0) should return 0 not the empty string

pencil
Priority: Normal
Current State: Closed
Released In: 2.1.7
Target Release: patch
Applies To: Extension
Component: SpreadSheetPlugin
Branches: Release02x01 master
Reported By: MichaelDaum
Waiting For:
Last Change By: MichaelDaum
Test:

%CALCULATE{"Foo$EVAL(0)Bar"}% = Foo0Bar .... should be Foo0Bar

Hotfix:

diff --git a/SpreadSheetPlugin/lib/Foswiki/Plugins/SpreadSheetPlugin/Calc.pm b/SpreadSheetPlugin/lib/Foswiki/Plugins/SpreadSheetPlugin/Calc.pm
index 7de7517c3..70309b5f1 100644
--- a/SpreadSheetPlugin/lib/Foswiki/Plugins/SpreadSheetPlugin/Calc.pm
+++ b/SpreadSheetPlugin/lib/Foswiki/Plugins/SpreadSheetPlugin/Calc.pm
@@ -1734,7 +1734,7 @@ sub _safeEvalPerl {
       s/(^|[^0-9])e/$1/g;   # remove "e"-s unless in expression such as "123e-4"
     $theText =~ /(.*)/;
     $theText = $1;          # untainted variable
-    return "" unless ($theText);
+    return "" unless defined ($theText);
     local $SIG{__DIE__} =
       sub { Foswiki::Func::writeDebug( $_[0] ); warn $_[0] };
     my $result = eval $theText;

-- MichaelDaum - 19 Jul 2018

 
Topic revision: r3 - 28 Mar 2022, MichaelDaum
The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. See Copyright Statement. Creative Commons License    Legal Imprint    Privacy Policy