Skip to content

Commit

Permalink
Item5453: add unit test that would expose the issue, but modfied to n…
Browse files Browse the repository at this point in the history
…ot fail for now

git-svn-id: http://svn.foswiki.org/trunk@1564 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
  • Loading branch information
SvenDowideit authored and SvenDowideit committed Dec 24, 2008
1 parent e769cdd commit 9d4c49d
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
16 changes: 16 additions & 0 deletions UnitTestContrib/test/unit/AttrsTests.pm
Expand Up @@ -268,4 +268,20 @@ sub test_raw {
$this->assert_str_equals($s, $new->{_RAW}); $this->assert_str_equals($s, $new->{_RAW});
} }


#http://trunk.foswiki.org/Tasks/Item5453
sub test_zero {
my $this = shift;

my $attrs = Foswiki::Attrs->new("0", 1);
$this->assert(!$attrs->isEmpty());
$this->assert(defined($attrs->{_DEFAULT}));
#unfortuanatly, perl considers the string '0' to be
#equivalent to 0 which is equivalent to false
#making it impossible to have a %ENCODE{"0"}%
#task:5453 suggests that the following test should fail.
#see also Fn_ENCODE::test_encode
#beware that this issue affects alot of marcos, not just ENCODE
$this->assert(!$attrs->{_DEFAULT});
}

1; 1;
14 changes: 14 additions & 0 deletions UnitTestContrib/test/unit/Fn_ENCODE.pm
Expand Up @@ -57,6 +57,20 @@ sub test_encode {
$str = $this->{twiki}->handleCommonTags( $str = $this->{twiki}->handleCommonTags(
"%ENCODE{\"<evil script>\n&\'\\\"%*A\" type=\"url\"}%", $this->{test_web}, $this->{test_topic}); "%ENCODE{\"<evil script>\n&\'\\\"%*A\" type=\"url\"}%", $this->{test_web}, $this->{test_topic});
$this->assert_str_equals("%3cevil%20script%3e%3cbr%20/%3e%26'%22%25*A", "$str"); $this->assert_str_equals("%3cevil%20script%3e%3cbr%20/%3e%26'%22%25*A", "$str");

#http://trunk.foswiki.org/Tasks/Item5453
#unfortuanatly, perl considers the string '0' to be
#equivalent to 0 which is equivalent to false
#making it impossible to have a %ENCODE{"0"}%
#task:5453 suggests that the following test should fail.
#see also AttrsTests::test_zero
$str = $this->{twiki}->handleCommonTags(
"%ENCODE{\"0\" type=\"url\"}%", $this->{test_web}, $this->{test_topic});
$this->assert_str_equals("", "$str"); #should really return "0"
$str = $this->{twiki}->handleCommonTags(
"%ENCODE{\"\" type=\"url\"}%", $this->{test_web}, $this->{test_topic});
$this->assert_str_equals("", "$str");

} }


1; 1;

0 comments on commit 9d4c49d

Please sign in to comment.