Another bug in HTML::BBCode

Another bug in HTML::BBCode

am 04.11.2005 17:01:12 von YorHel

Hello,

It seems like HTML::BBCode does have a list of bugs, this is the second
one I noticed in a few days. This time, the bug is in the [code]-block,
have a look at the following script:

#!/bin/perl

use strict;
use warnings;
use HTML::BBCode;

my $bbc = HTML::BBCode->new({
no_html => 1,
linebreaks => 1 });

my $bbcode=<<'BBCODE';
[code]
[u]some code[/u]
[/code]
BBCODE

print $bbc->parse($bbcode);
__END__

This will incorrectly output:

Code:
class="bbcode_code_body"> /> <span style="text-decoration: underline;">some code</span >  />


When displayed in a web browser, you'll notice that you don't see the
[u] and [/u] BBCodes, but the HTML-output it generates.
I also made a patch for this bug, here's the diff (this diff includes
the modifications I made a few posts ago, to fix the [list]-bug):

171c171,172
< if($self->{_skip_nest} ne '' && $end ne
"[/$self->{_skip_nest}]") {
---
> if(($self->{_skip_nest} ne '' && $end ne "[/$self->{_skip_nest}]") ||
> ($self->{_in_code_block} && $end ne "[/code]")) {
181c182,186
< _open_tag($self, $1);
---
> if($self->{_in_code_block}) {
> _content($self, $1);
> } else {
> _open_tag($self, $1);
> }
353c358,360
< $content =~ s|\[\*\]([^(\[]+)|
  • $1
  • |gs;
    ---
    > $content =~ s|^
    \n|\n|s;
    > # $content =~ s|\[\*\]([^(\[]+)|
  • $1
  • |gs;
    > $content =~ s|\[\*\]([^(\[]+)|_list_removelastbr($1)|egs;
    362a370,374
    > sub _list_removelastbr {
    > my $content = shift;
    > $content =~ s|
    [\s\r\n]*$||;
    > return "
  • $content
  • \n";
    > }

    I'll also notify the author of HTML::BBCode.

    greets, YorHel