Permalink
Browse files

Item5453: add unit test that would expose the issue, but modfied to n…

…ot fail for now

git-svn-id: http://svn.foswiki.org/trunk@1564 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
  • Loading branch information...
SvenDowideit SvenDowideit
SvenDowideit authored and SvenDowideit committed Dec 24, 2008
1 parent e769cdd commit 9d4c49d9e2dde4e8416552eed940dcf197cc8a82
Showing with 30 additions and 0 deletions.
  1. +16 −0 UnitTestContrib/test/unit/AttrsTests.pm
  2. +14 −0 UnitTestContrib/test/unit/Fn_ENCODE.pm
@@ -268,4 +268,20 @@ sub test_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;
@@ -57,6 +57,20 @@ sub test_encode {
$str = $this->{twiki}->handleCommonTags(
"%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");
#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;

0 comments on commit 9d4c49d

Please sign in to comment.