Some variables do not work properly if the value given as an argument is (or expands to) the string "0".
For example, %
ENCODE{"% FORMFIELD{"myField"} %" type="..."} % renders as an empty string if myField has the value "0". A more direct example: 0 (see raw view for the code that fails to render here).
This is because Perl considers "0" equivalent to 0 and logically false. So it appears that this code (taken from lib/TWiki.pm around line 3060) replaces the input parameter of "0" with the default value "":
my $text = $params->{_DEFAULT} || '';
Not sure how common this is in the codebase; have only encountered/confirmed the error with ENCODE so far. This is a significant problem as some of my forms have numeric fields or other fields that can reasonably (even commonly) assume the value "0", and a workaround in the wiki markup is possible but not easy (and maybe not efficient).
--
TWiki:Main/MarkAdelsberger - 18 Mar 2008
Fixed for ENCODE, to be released in 4.3.1.
Test:
-
%ENCODE{ "" type="entity" }%:
>><<
-
%ENCODE{ "0" type="entity" }%:
>>0<<
-
%ENCODE{ "1" type="entity" }%:
>>1<<
-
%ENCODE{ "&" type="entity" }%:
>>&<<
I checked other variables. Although there are instances where empty and value
0
is treated erroneously as the same, it is unlike that it will be used as such. Found in INCLUDE, TOC, STARTSECTION, ENDSECTION, GMTIME, SERVERTIME, DISPLAYTIME, REVINFO, WEBLIST, TOPICLIST, URLPARAM, ICON, MAKETEXT, SCRIPTURL, META.
Changing item summary to reflect this.
--
TWiki:Main.PeterThoeny - 09 Apr 2009