Subject: | [b]foo[/B] not working when providing a callback [PATCH] |
Patch with tests attached.
Subject: | Parse-BBCode-casing.patch |
diff -Nru Parse-BBCode-0.13/lib/Parse/BBCode.pm Parse-BBCode-0.13-nicomen/lib/Parse/BBCode.pm
--- Parse-BBCode-0.13/lib/Parse/BBCode.pm 2011-08-19 12:06:24.000000000 +0000
+++ Parse-BBCode-0.13-nicomen/lib/Parse/BBCode.pm 2011-09-14 13:28:51.000000000 +0000
@@ -548,7 +548,7 @@
else {
#warn __PACKAGE__.':'.__LINE__.": noparse, find content\n";
# just search for closing tag
- if ($after =~ s# (.*?) (\[ / $tag \]) ##xs) {
+ if ($after =~ s# (.*?) (\[ / $tag \]) ##ixs) {
my $content = $1;
my $end = $2;
#warn __PACKAGE__.':'.__LINE__.": CONTENT $content\n";
diff -Nru Parse-BBCode-0.13/t/16_casing.t Parse-BBCode-0.13-nicomen/t/16_casing.t
--- Parse-BBCode-0.13/t/16_casing.t 1970-01-01 00:00:00.000000000 +0000
+++ Parse-BBCode-0.13-nicomen/t/16_casing.t 2011-09-14 13:37:43.000000000 +0000
@@ -0,0 +1,54 @@
+use Test::More tests => 12;
+use Parse::BBCode;
+use strict;
+use warnings;
+
+my $repl = 'repl';
+
+my $p = Parse::BBCode->new({
+ tags => {
+ b => $repl,
+ },
+ }
+);
+
+my $pns = Parse::BBCode->new({
+ tags => {
+ b => $repl,
+ },
+ strict_attributes => 0,
+ }
+);
+
+my @tests = (
+ [ qq#[b]a[/b]#, $repl],
+ [ qq#[b]a[/B]#, $repl],
+ [ qq#[B]a[/B]#, $repl],
+ [ qq#[B]a[/b]#, $repl],
+
+ [ qq#[b=foo]a[/b]#, $repl],
+ [ qq#[b=foo]a[/B]#, $repl],
+ [ qq#[B=foo]a[/B]#, $repl],
+ [ qq#[B=foo]a[/b]#, $repl],
+
+ [ qq#[b haha haha]a[/b]#, $repl, undef, $pns],
+ [ qq#[b haha haha]a[/B]#, $repl, undef, $pns],
+ [ qq#[B haha haha]a[/B]#, $repl, undef, $pns],
+ [ qq#[B haha haha]a[/b]#, $repl, undef, $pns],
+);
+
+for my $test (@tests) {
+ my ($text, $exp, $forbid, $parser) = @$test;
+ $parser ||= $p;
+ if ($forbid) {
+ $parser->forbid($forbid);
+ }
+ my $parsed = $parser->render($text);
+ #warn __PACKAGE__.':'.__LINE__.": $parsed\n";
+ s/[\r\n]//g for ($exp, $parsed);
+ $text =~ s/[\r\n]//g;
+ cmp_ok($parsed, 'eq', $exp, "parse '$text'");
+}
+
+
+