BBCode/StripScripts.pm

filter: Statementstmt 100% 34 / 34 Branchbran 91.6% 11 / 12 Conditioncond 50.0% 3 / 6 MC/DCmcdc 25.0% 1 / 4 Subroutinesub 100% 6 / 6 Podpod 100% 3 / 3 totaltotal 89.2% 58 / 65 CC 9 SCAR 14.8
CC
9
Cov
92%
validate_href_attribute
7.2
init_attrib_whitelist
2.0
init_style_whitelist
2.0
CRAP 4.4
« BBCode.pm ↑ Summary
1 package HTML::BBCode::StripScripts;
2  
3 17 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 17 ▶use URI;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 17 ▶use base qw(HTML::StripScripts::Parser);
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 17 our $VERSION = '0.04';
8  
9 17 my %bbattrib;
10 my %bbstyle;
11 17 my %bbstyle_overrides = (
12 'text-decoration' => 'word',
13 'font-style' => 'word',
14 'font-weight' => 'word',
15 'list-style-type' => 'word',
16 );
17  
18  
19 24 ▶sub init_attrib_whitelist {
Subroutine init_attrib_whitelist: called CC=2 SCAR=6.9
Pod documented
20 24 ▶ unless (%bbattrib) {
Branch: 1 branch
BranchTrueFalseTotal
unless (%bbattrib) 17 7 24
21 17 %bbattrib = %{__PACKAGE__->SUPER::init_attrib_whitelist};
22 17 $bbattrib{'h5'}{'class'} = 'word';
23 }
24 24 return \%bbattrib;
25 }
26  
27 24 ▶sub init_style_whitelist {
Subroutine init_style_whitelist: called CC=2 SCAR=6.9
Pod documented
28 24 ▶ unless (%bbstyle) {
Branch: 1 branch
BranchTrueFalseTotal
unless (%bbstyle) 17 7 24
29 17 %bbstyle = %{__PACKAGE__->SUPER::init_style_whitelist};
30 17 @bbstyle{keys %bbstyle_overrides} = values %bbstyle_overrides;
31 }
32 24 return \%bbstyle;
33 }
34  
35 16 ▶sub validate_href_attribute {
Subroutine validate_href_attribute: called CC=7 SCAR=19.7
Pod documented
36 16 my ($self, $text) = @_;
37  
38 # Encode URLs if needed (as per bug 31927)
39 16 my $uri = URI->new($text);
40 16 my $query = $uri->query;
41 16 ▶ if($query) {
Branch: 1 branch
BranchTrueFalseTotal
if ($query) 5 11 16
42 5 ▶ if($query =~ m/[^A-Za-z0-9\-_.!~*'()]/ && $query !~ m/%(?![A-Fa-f0-9])/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($query =~ /[^A-Za-z0-9\-_.!~*'()]/ and not $query =~ /%(?![A-Fa-f0-9])/) 5 0 5
Condition33%1/3
$query =~ /[^A-Za-z0-9\-_.!~*'()]/ and not $query =~ /%(?![A-Fa-f0-9])/
!ll&&!rl&&r
005
MC/DC0%0/2
$query =~ /[^A-Za-z0-9\-_.!~*'()]/ and not $query =~ /%(?![A-Fa-f0-9])/
$query =~ /[^A-Za-z0-9\-_.!~*'()]/ not $query =~ /%(?![A-Fa-f0-9])/
Truth table33%1/3
A and not(B)
A= $query =~ /[^A-Za-z0-9\-_.!~*'()]/B= not $query =~ /%(?![A-Fa-f0-9])/
ABresult
0X0
100
111
43 5 $query =~ s/([^;&=A-Za-z0-9\-_.!~*'()\%])/sprintf("%%%02X", ord($1))/ge;
44 5 $uri->query($query);
45 }
46 }
47  
48 16 $text = $uri->as_string;
49  
50 return $1
51 if $self->{_hssCfg}{AllowRelURL}
52 16 ▶ and $text =~ /^((?:[\w\-.!~*|;\/?=+\$,%#]|&){0,100})$/;
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"_hssCfg"}{"AllowRelURL"} and $text =~ m[^((?:[\w\-.!~*|;/?=+\$,%#]|&){0,100})$] 1 15 16
Condition66%2/3
$self->{"_hssCfg"}{"AllowRelURL"} and $text =~ m[^((?:[\w\-.!~*|;/?=+\$,%#]|&){0,100})$]
!ll&&!rl&&r
0151
MC/DC50%1/2
$self->{"_hssCfg"}{"AllowRelURL"} and $text =~ m[^((?:[\w\-.!~*|;/?=+\$,%#]|&){0,100})$]
$self->{"_hssCfg"}{"AllowRelURL"} $text =~ m[^((?:[\w\-.!~*|;/?=+\$,%#]|&){0,100})$]
Truth table66%2/3
A and B
A= $self->{"_hssCfg"}{"AllowRelURL"}B= $text =~ m[^((?:[\w\-.!~*|;/?=+\$,%#]|&){0,100})$]
ABresult
0X0
100
111
53  
54 15 ▶ $text =~ m< ^ ( (f|ht)tps? :// [\w\-\.]{1,100} (?:\:\d{1,5})?
Branch: 1 branch
BranchTrueFalseTotal
$text =~ m[ ^ ( (f|ht)tps? :// [\w\-\.]{1,100} (?:\:\d{1,5})? (?: / (?:[\w\-.!~*|;/?=+\$,%#]|&amp;){0,2000} )? ) $ ]x ? : 13 2 15
55 (?: / (?:[\w\-.!~*|;/?=+\$,%#]|&amp;){0,2000} )?
56 )
57 $
58 >x ? $1 : undef;
59 }
60  
61  
62 17 1;
« BBCode.pm ↑ Summary