This question about Using an extension: Answered

when list has zero in it - filterplugin don't work

example: FORMATLIST{"0,1,2,3" format=" * $1" separator="$n"} will display:

  • 0
  • 1
  • 2
  • 3

so 0 is missing...

problem is in handleFormatList function - earch argument is detected with code $arg1 = $1 || ''; - so, when $1 is '0', perl converts it to int and 0 means false - so $arg1 get assigned '' as its value.

patch (which also solve problem when you five FORMATLIST list with 1 element which is zero - ie.: FORMATLIST{"0"}):

--- Core.pm 2011-04-06 13:08:53.000000000 +0200
+++ Core.pm.new 2011-07-13 09:25:02.000000000 +0200
@@ -502,7 +502,9 @@ sub handleFormatList {

   #writeDebug("handleFormatList(".$params->stringify().")");

-  my $theList = $params->{_DEFAULT} || $params->{list} || '';
+  my $theList = defined($params->{_DEFAULT}) ? $params->{_DEFAULT} :
+    defined($params->{list}) ? $params->{list} :
+    '';
   my $thePattern = $params->{pattern} || '^\s*(.*?)\s*$';
   my $theFormat = $params->{format};
   my $theHeader = $params->{header} || '';
@@ -588,16 +590,16 @@ sub handleFormatList {
     my $arg9 = '';
     my $arg10 = '';
     if ($item =~ m/$thePattern/) {
-      $arg1 = $1 || '';
-      $arg2 = $2 || '';
-      $arg3 = $3 || '';
-      $arg4 = $4 || '';
-      $arg5 = $5 || '';
-      $arg6 = $6 || '';
-      $arg7 = $7 || '';
-      $arg8 = $8 || '';
-      $arg9 = $9 || '';
-      $arg10 = $10 || '';
+      $arg1 = defined($1) ? $1 : '';
+      $arg2 = defined($2) ? $2 : '';
+      $arg3 = defined($3) ? $3 : '';
+      $arg4 = defined($4) ? $4 : '';
+      $arg5 = defined($5) ? $5 : '';
+      $arg6 = defined($6) ? $6 : '';
+      $arg7 = defined($7) ? $7 : '';
+      $arg8 = defined($8) ? $8 : '';
+      $arg9 = defined($9) ? $9 : '';
+      $arg10 = defined($10) ? $10 : '';
     } else {
       next;
     }


Hello Grzegorz, I have created Tasks.Item10965, where the author of FilterPlugin is more likely to see this report.

Thank you for the patch!

-- PaulHarvey - 14 Jul 2011

Fixed in FilterPlugin 2.05

-- MichaelDaum - 14 Jul 2011

QuestionForm edit

Subject Using an extension
Extension FilterPlugin
Version Foswiki 1.1.3
Status Answered
Related Topics Tasks.Item10965
Topic revision: r3 - 14 Jul 2011, 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