Skip to content

Commit

Permalink
Item11349: Fixed ::Address->parse('..@123') bug
Browse files Browse the repository at this point in the history
Apparently the existing code blew up occasionally - regex capture
variables from a s/// weren't as deterministic as the author thought

git-svn-id: http://svn.foswiki.org/trunk@13374 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
  • Loading branch information
PaulHarvey authored and PaulHarvey committed Dec 11, 2011
1 parent 6cb3221 commit f1b75d2
Showing 1 changed file with 23 additions and 6 deletions.
29 changes: 23 additions & 6 deletions core/lib/Foswiki/Address.pm
Original file line number Diff line number Diff line change
Expand Up @@ -509,9 +509,14 @@ sub parse {
};
}
%opts = ( %{ $this->{parseopts} }, %opts );
ASSERT(
( !defined $opts{rev} || $opts{rev} =~ /^[-\+]?\d+$/ ),
"rev: '" . ( $opts{rev} ? $opts{rev} : 'undef' ) . "' is numeric"
) if DEBUG;
ASSERT( $opts{isA} or defined $opts{existAs} ) if DEBUG;
$path =~ s/(\@([-\+]?\d+))$//;
$this->{rev} = $2;
if ( $path =~ s/\@([-\+]?\d+)$// ) {
$this->{rev} = $1;
}

# if necessary, populate webpath from web parameter
if ( not $opts{webpath} and $opts{web} ) {
Expand Down Expand Up @@ -750,11 +755,11 @@ sub _atomiseAsWeb {

sub _atomiseAsTopic {
my ( $this, $that, $path, $opts ) = @_;
ASSERT($path) if DEBUG;
my @parts = split( /[\.\/]/, $path );
my $nparts = scalar(@parts);

print STDERR "_atomiseAsTopic(): path: $path, nparts: $nparts\n" if TRACE2;
ASSERT($path) if DEBUG;
if ( $nparts == 1 ) {
if ( $opts->{webpath}
and ref( $opts->{webpath} ) eq 'ARRAY'
Expand Down Expand Up @@ -876,7 +881,7 @@ sub _atomiseAsTOM {
$/x
)
{
my $topic = $2;
my $webtopicrev = $2;
my @tompath;
my $doneselector;
my $doneaccessor;
Expand Down Expand Up @@ -962,9 +967,9 @@ sub _atomiseAsTOM {
push( @tompath, $14 );
}
$that->{tompath} = \@tompath;
if ($topic) {
if ($webtopicrev) {
my $refAddr = Foswiki::Address->new(
string => $topic,
string => $webtopicrev,
isA => 'topic',
webpath => $opts->{webpath},
web => $opts->{web}
Expand All @@ -974,6 +979,12 @@ sub _atomiseAsTOM {
$that->{webpath} = $refAddr->{webpath};
$that->{topic} = $refAddr->{topic};
$that->{rev} = $refAddr->{rev};
ASSERT(
( !defined $that->{rev} || $that->{rev} =~ /^[-\+]?\d+$/ ),
"rev '"
. ( defined $that->{rev} ? $that->{rev} : 'undef' )
. "' is numeric"
) if DEBUG;
}
else {
$that->{webpath} = $opts->{webpath};
Expand Down Expand Up @@ -1473,6 +1484,12 @@ sub isValid {
else {
$this->{isA} = {};
}
ASSERT(
( !defined $this->{rev} || $this->{rev} =~ /^[-\+]?\d+$/ ),
"rev '"
. ( defined $this->{rev} ? $this->{rev} : 'undef' )
. "' is numeric"
) if DEBUG;
}

return $this->{type};
Expand Down

0 comments on commit f1b75d2

Please sign in to comment.