• Do not register here on develop.twiki.org, login with your twiki.org account.
• Use View topic Item7848 for generic doc work for TWiki-6.1.1. Use View topic Item7851 for doc work on extensions that are not part of a release. More... Close
• Anything you create or change in standard webs (Main, TWiki, Sandbox etc) will be automatically reverted on every SVN update.
Does this site look broken?. Use the LitterTray web for test cases.

Item5453: Value of "0" improperly handled in ENCODE variable

Item Form Data

AppliesTo: Component: Priority: CurrentState: WaitingFor: TargetRelease ReleasedIn
Engine   Normal Closed   patch 4.3.1, 5.0.0

Edit Form Data

Reported By:
Applies To:
Current State:
Waiting For:
Target Release:
Released In:


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.


  • %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

Summary Value of "0" improperly handled in ENCODE variable
ReportedBy TWiki:Main.MarkAdelsberger
Codebase 4.1.2, 4.2.0, 4.2.1, 4.2.2, 4.2.3, 4.2.4, 4.3.0, ~twiki4
SVN Range TWiki-5.0.0, Sun, 09 Mar 2008, build 16496
AppliesTo Engine

Priority Normal
CurrentState Closed

Checkins TWikirev:17969 TWikirev:17970
TargetRelease patch
ReleasedIn 4.3.1, 5.0.0
Edit | Attach | Watch | Print version | History: r5 < r4 < r3 < r2 < r1 | Backlinks | Raw View |  Raw edit | More topic actions
Topic revision: r5 - 2009-05-03 - PeterThoeny
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2021 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback