From f7d7f6324ff7fb657e19f364eaf21358abf04850 Mon Sep 17 00:00:00 2001 From: MichaelTempest Date: Thu, 19 Aug 2010 20:09:41 +0000 Subject: [PATCH] Item9502: Use default values for revision numbers for change summary if the values supplied aren't numeric or aren't in the proper order. git-svn-id: http://svn.foswiki.org/trunk@8596 0b4bb1d4-4e5a-0410-9cc4-b2b747904278 --- core/lib/Foswiki/Meta.pm | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/core/lib/Foswiki/Meta.pm b/core/lib/Foswiki/Meta.pm index 549739dd68..1b3e4e6368 100644 --- a/core/lib/Foswiki/Meta.pm +++ b/core/lib/Foswiki/Meta.pm @@ -110,6 +110,7 @@ use warnings; use Error qw(:try); use Assert; use Errno 'EINTR'; +use Scalar::Util (); our $reason; our $VERSION = '$Rev$'; @@ -3132,9 +3133,9 @@ sub summariseChanges { ASSERT( $this->{_web} && $this->{_topic}, 'this is not a topic object' ) if DEBUG; - $nrev = $this->getLatestRev() unless $nrev; + $nrev = $this->getLatestRev() unless $nrev and _looks_like_number($nrev); - $orev = $nrev - 1 unless defined($orev); + $orev = $nrev - 1 unless defined($orev) and _looks_like_number($orev) and $nrev >= $orev; ASSERT( $orev >= 0 ) if DEBUG; ASSERT( $nrev >= $orev ) if DEBUG; @@ -3569,6 +3570,15 @@ sub dataDecode { return $datum; } +sub _looks_like_number { + if (0 and $] >= 5.008001) { + return Scalar::Util::looks_like_number( $_[0] ); + } + else { + return (defined $_[0] && $_[0] =~ /^\s*[+-]?\d+\s*$/); + } +} + 1; __END__ Module of Foswiki - The Free and Open Source Wiki, http://foswiki.org/, http://Foswiki.org/