From 250428d603130a0764fd66aef77498c8c64cf9c4 Mon Sep 17 00:00:00 2001 From: George Clark Date: Thu, 2 Apr 2015 11:31:34 -0400 Subject: [PATCH] Item13347: istopic on empty topic name returns true --- UnitTestContrib/test/unit/Fn_IF.pm | 11 +++++++++++ core/lib/Foswiki/If/OP_istopic.pm | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/UnitTestContrib/test/unit/Fn_IF.pm b/UnitTestContrib/test/unit/Fn_IF.pm index 054033325e..4160db8922 100644 --- a/UnitTestContrib/test/unit/Fn_IF.pm +++ b/UnitTestContrib/test/unit/Fn_IF.pm @@ -1175,6 +1175,17 @@ sub test_93b { return; } +sub test_Item13347 { + my $this = shift; + $this->simpleTest( + test => "istopic ''", + then => 0, + else => 1 + ); + + return; +} + sub test_93c { my $this = shift; $this->simpleTest( diff --git a/core/lib/Foswiki/If/OP_istopic.pm b/core/lib/Foswiki/If/OP_istopic.pm index 2adac7a667..888bb01f8d 100644 --- a/core/lib/Foswiki/If/OP_istopic.pm +++ b/core/lib/Foswiki/If/OP_istopic.pm @@ -36,7 +36,7 @@ sub evaluate { 'No context in which to evaluate "' . $a->stringify() . '"' ) unless $session; my ( $web, $topic ) = ( $session->{webName}, $a->_evaluate(@_) ); - return 0 unless defined $topic; # null topic cannot possibly exist + return 0 unless $topic; # null/empty topic cannot possibly exist ( $web, $topic ) = $session->normalizeWebTopicName( $web, $topic ); return $session->topicExists( $web, $topic ) ? 1 : 0; }