This file is indexed.

/usr/share/doc/libparse-bbcode-perl/examples/compare.pl is in libparse-bbcode-perl 0.15-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
#!/usr/bin/perl
use strict;
use warnings;
use Carp qw(carp croak);
use Data::Dumper;

use BBCode::Parser;
use Parse::BBCode;
use HTML::BBCode;
use HTML::BBReverse;
use AUBBC;

my %subs = (
    'BBCode::Parser'  => \&parse_bb_parser,
    'Parse::BBCode'   => \&parse_p_bb,
    'HTML::BBCode'    => \&parse_html_bb,
    'HTML::BBReverse' => \&parse_bbr,
    'AUBBC'           => \&parse_aubbc,
);

my $unbalanced = <<'EOM';
[i]italic [b]bold[/b]
EOM
my $unbalanced2 = <<'EOM';
[i]italic [b]bold[/i]
EOM
my $unbalanced3 = <<'EOM';
[i]italic [code]bold[/i]
EOM
my $unknown = <<'EOM';
[some]unknown[/unknown] tag
EOM
my $forbidden = <<'EOM';
[img]forbidden[/img]
EOM
my $block = <<'EOM';
[i] italic [code]code block[/code] [/i]
EOM
my $list = <<'EOM';
[list] [*]first [*] second [/list]
EOM
my $image = <<'EOM';
[img]image.png[/img]
[img="image.png"]text[/img]
EOM
my $url = <<'EOM';
[b]test[/b] http://perl.org/
EOM
#[img=image.png][/img]
#[img=image.png]text with [b]bold[/b][/img]
#[img=image.png]text with "" quotes[/img]

my %codes = (
    unbalanced => $unbalanced,
    unbalanced2 => $unbalanced2,
    unbalanced3 => $unbalanced3,
    unknown => $unknown,
    forbidden => $forbidden,
    block => $block,
    list => $list,
    image => $image,
	url => $url,
);

for my $key (sort keys %subs) {
    my $v = $key->VERSION;
    print "\n$key\t$v\n";
    my $sub = $subs{$key};
    for my $name (sort keys %codes) {
        my $code = $codes{$name};
        my $out;
		print "======= $key $name:\n";
		my $forbid = $name eq 'forbidden' ? 1 : 0;
        eval {
            $out = $sub->($code, $forbid);
        };
        if ($@) {
            print "$key $name dies: $@\n";
            print <<"EOM";
$code=======

EOM
        }
        else {
            print "$key $name does not die\n";
            print <<"EOM";
$code=======
$out
=======

EOM
        }
    }
}



sub parse_bb_parser {
    my ($code, $forbid) = @_;
    my $p = BBCode::Parser->new(follow_links => 1);
    if ($forbid) {
        $p->forbid('IMG');
    }
    my $tree = $p->parse($code);
    my $out = $tree->toHTML();
}

sub parse_aubbc {
    my ($code, $forbid) = @_;
    my $p;
    if ($forbid) {
        $p = AUBBC->new( no_img => 1 );
    }
    else {
        $p = AUBBC->new();
    }
    my $out = $p->do_all_ubbc($code);
}

sub parse_p_bb {
    my ($code, $forbid) = @_;
    my $p = Parse::BBCode->new({
        tags => {
            b => '<b>%s</b>',
            i => '<i>%s</i>',
            url => '<a href="%{link}A">%s</a>',
            code =>'block:<div class="bbcode-code">
<div class="bbcode-code-head">Code:</div>
<pre class="bbcode-code-body">%{noparse}s
</pre>
</div>',
            'img' => '<img src="%{html}A" alt="%{html}s" title="%{html}s">',
        },
    });
	if ($forbid) {
		$p->forbid(qw/ img /);
	}
    my $out = $p->render($code);
}

sub parse_html_bb {
    my ($code, $forbid) = @_;
    my $p;
    if ($forbid) {
        $p = HTML::BBCode->new({
            allowed_tags => [
                qw/ b i code url list /
            ],
        });
    }
    else {
        $p = HTML::BBCode->new();
    }
    my $out = $p->parse($code);
}

sub parse_bbr {
    my ($code, $forbid) = @_;
    my $p;
    if ($forbid) {
        $p = HTML::BBReverse->new(
            allowed_tags => [
                qw/ b i code url list /
            ],
        );
    }
    else {
        $p = HTML::BBReverse->new(
        );
    }
    my $out = $p->parse($code);
}