Changeset 401 for veekun/trunk

Show
Ignore:
Timestamp:
01/31/08 11:35:54 (10 months ago)
Author:
eevee
Message:

Fix for an infinite loop in bbcode parser. A replaced tag with content containing a newline would loop forever.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • veekun/trunk/lib/Vee/BBCode.pm

    r111 r401  
    3232# BUGS: 
    3333#  - replace won't work with no_close 
     34#  - replace won't work when nested 
    3435our %tags = ( 
    3536    b       => { param => 0, start => '<strong class="bbcode-b">', end => '</strong>' }, 
     
    8485    for my $tag (keys %tags) { 
    8586        if (exists $tags{$tag}{replace}) { 
    86             while ( $input =~ /\[$tag[]=]/ ) { 
    87                 $input =~ s: (.*) \[ $tag \] (.+?) \[ / $tag \] : $1 . $tags{$tag}{replace}->(undef, $2) :gexi; 
    88                 $input =~ s: (.*) \[ $tag = (.+?) \] (.+?) \[ / $tag \] : $1 . $tags{$tag}{replace}->($2, $3) :gexi; 
    89             } 
     87            $input =~ s: (.*) \[ $tag \] (.+?) \[ / $tag \] : $1 . $tags{$tag}{replace}->(undef, $2) :gexis; 
     88            $input =~ s: (.*) \[ $tag = (.+?) \] (.+?) \[ / $tag \] : $1 . $tags{$tag}{replace}->($2, $3) :gexis; 
    9089        } else { 
    9190            $input =~ s: \[ $tag \] : $tags{$tag}{start}->() :gexi;