| 1 | package POE::Component::IRC::Plugin::Validator::CSS; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | 1 | our $VERSION = '2.001004'; # VERSION | |||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 1 | ▶ | use Carp; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 1 | ▶ | use POE qw(Component::WebService::Validator::CSS::W3C); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | 1 | ▶ | use POE::Component::IRC::Plugin qw(:ALL); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | 1 | ▶ | use LWP::UserAgent; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | 0 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||
| 14 | 0 | my $class = shift; | |||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | 0 | ▶ | croak "Must have even number of arguments to new()" | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 17 | if @_ & 1; | ||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | 0 | my %args = @_; | |||||||||||||||||||||||||||
| 20 | 0 | $args{ lc $_ } = delete $args{ $_ } for keys %args; | |||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | # fill in the defaults. | ||||||||||||||||||||||||||||
| 23 | 0 | %args = ( | |||||||||||||||||||||||||||
| 24 | auto => 1, | ||||||||||||||||||||||||||||
| 25 | eat => 1, | ||||||||||||||||||||||||||||
| 26 | trigger => qr/^cssval\s+(?=\S)/i, | ||||||||||||||||||||||||||||
| 27 | addressed => 1, | ||||||||||||||||||||||||||||
| 28 | listen_for_input => [ qw(public notice privmsg) ], | ||||||||||||||||||||||||||||
| 29 | response_event => 'irc_css_validator_response', | ||||||||||||||||||||||||||||
| 30 | valid_format => '([:[uri_short]:]) Valid ' | ||||||||||||||||||||||||||||
| 31 | . '( [:[refer_to_uri]:] )', | ||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | invalid_format => '([:[uri_short]:]) Invalid, ' | ||||||||||||||||||||||||||||
| 34 | . '[:[num_errors]:] error(s), see: ' | ||||||||||||||||||||||||||||
| 35 | . '[:[refer_to_uri]:]', | ||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | banned => [], | ||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | %args, | ||||||||||||||||||||||||||||
| 40 | ); | ||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | 0 | ▶ | unless ( exists $args{poco_args}{ua} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 43 | 0 | $args{poco_args}{ua} = LWP::UserAgent->new( timeout => 15 ); | |||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | $args{listen_for_input} = { | ||||||||||||||||||||||||||||
| 47 | 0 | ▶ | map { $_ => 1 } @{ $args{listen_for_input} || [] } | ||||||||||||||||||||||||||
|
Condition0%0/2
$args{'listen_for_input'} || []
MC/DC0%0/1
$args{'listen_for_input'} || []
$args{'listen_for_input'}
Truth table0%0/2
A
A= $args{'listen_for_input'}
| |||||||||||||||||||||||||||||
| 48 | }; | ||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | 0 | return bless \%args, $class; | |||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | 0 | ▶ | sub PCI_register { | ||||||||||||||||||||||||||
|
Subroutine
PCI_register: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 54 | 0 | my ( $self, $irc ) = splice @_, 0, 2; | |||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | 0 | $self->{irc} = $irc; | |||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||
| 58 | 0 | $irc->plugin_register( $self, 'SERVER', qw(notice public msg) ); | |||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||
| 60 | 0 | $self->{_session_id} = POE::Session->create( | |||||||||||||||||||||||||||
| 61 | object_states => [ | ||||||||||||||||||||||||||||
| 62 | $self => [ | ||||||||||||||||||||||||||||
| 63 | qw( | ||||||||||||||||||||||||||||
| 64 | _start | ||||||||||||||||||||||||||||
| 65 | _shutdown | ||||||||||||||||||||||||||||
| 66 | _start_val | ||||||||||||||||||||||||||||
| 67 | _validated | ||||||||||||||||||||||||||||
| 68 | ) | ||||||||||||||||||||||||||||
| 69 | ] | ||||||||||||||||||||||||||||
| 70 | ], | ||||||||||||||||||||||||||||
| 71 | )->ID; | ||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||
| 73 | 0 | return 1; | |||||||||||||||||||||||||||
| 74 | } | ||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||
| 76 | 0 | ▶ | sub _start { | ||||||||||||||||||||||||||
|
Subroutine
_start: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 77 | 0 | my ( $kernel, $self ) = @_[ KERNEL, OBJECT ]; | |||||||||||||||||||||||||||
| 78 | 0 | $self->{_session_id} = $_[SESSION]->ID(); | |||||||||||||||||||||||||||
| 79 | 0 | $kernel->refcount_increment( $self->{_session_id}, __PACKAGE__ ); | |||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||
| 81 | $self->{poco} = POE::Component::WebService::Validator::CSS::W3C->spawn( | ||||||||||||||||||||||||||||
| 82 | 0 | ▶ | %{ $self->{poco_args} || {} } | ||||||||||||||||||||||||||
|
Condition0%0/2
$self->{'poco_args'} || {}
MC/DC0%0/1
$self->{'poco_args'} || {}
$self->{'poco_args'}
Truth table0%0/2
A
A= $self->{'poco_args'}
| |||||||||||||||||||||||||||||
| 83 | ); | ||||||||||||||||||||||||||||
| 84 | 0 | undef; | |||||||||||||||||||||||||||
| 85 | } | ||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||
| 87 | 0 | ▶ | sub _shutdown { | ||||||||||||||||||||||||||
|
Subroutine
_shutdown: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 88 | 0 | my ($kernel, $self) = @_[ KERNEL, OBJECT ]; | |||||||||||||||||||||||||||
| 89 | 0 | $self->{poco}->shutdown; | |||||||||||||||||||||||||||
| 90 | 0 | $kernel->alarm_remove_all(); | |||||||||||||||||||||||||||
| 91 | 0 | $kernel->refcount_decrement( $self->{_session_id}, __PACKAGE__ ); | |||||||||||||||||||||||||||
| 92 | 0 | undef; | |||||||||||||||||||||||||||
| 93 | } | ||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||
| 95 | 0 | ▶ | sub PCI_unregister { | ||||||||||||||||||||||||||
|
Subroutine
PCI_unregister: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 96 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||
| 98 | # Plugin is dying make sure our POE session does as well. | ||||||||||||||||||||||||||||
| 99 | 0 | $poe_kernel->call( $self->{_session_id} => '_shutdown' ); | |||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||
| 101 | 0 | delete $self->{irc}; | |||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||
| 103 | 0 | return 1; | |||||||||||||||||||||||||||
| 104 | } | ||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||
| 107 | 0 | ▶ | sub S_public { | ||||||||||||||||||||||||||
|
Subroutine
S_public: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 108 | 0 | my ( $self, $irc ) = splice @_, 0, 2; | |||||||||||||||||||||||||||
| 109 | 0 | my $who = ${ $_[0] }; | |||||||||||||||||||||||||||
| 110 | 0 | my $channel = ${ $_[1] }->[0]; | |||||||||||||||||||||||||||
| 111 | 0 | my $message = ${ $_[2] }; | |||||||||||||||||||||||||||
| 112 | 0 | return $self->_parse_input( $irc, $who, $channel, $message, 'public' ); | |||||||||||||||||||||||||||
| 113 | } | ||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||
| 115 | 0 | ▶ | sub S_notice { | ||||||||||||||||||||||||||
|
Subroutine
S_notice: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 116 | 0 | my ( $self, $irc ) = splice @_, 0, 2; | |||||||||||||||||||||||||||
| 117 | 0 | my $who = ${ $_[0] }; | |||||||||||||||||||||||||||
| 118 | 0 | my $channel = ${ $_[1] }->[0]; | |||||||||||||||||||||||||||
| 119 | 0 | my $message = ${ $_[2] }; | |||||||||||||||||||||||||||
| 120 | 0 | return $self->_parse_input( $irc, $who, $channel, $message, 'notice' ); | |||||||||||||||||||||||||||
| 121 | } | ||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||
| 123 | 0 | ▶ | sub S_msg { | ||||||||||||||||||||||||||
|
Subroutine
S_msg: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 124 | 0 | my ( $self, $irc ) = splice @_, 0, 2; | |||||||||||||||||||||||||||
| 125 | 0 | my $who = ${ $_[0] }; | |||||||||||||||||||||||||||
| 126 | 0 | my $channel = ${ $_[1] }->[0]; | |||||||||||||||||||||||||||
| 127 | 0 | my $message = ${ $_[2] }; | |||||||||||||||||||||||||||
| 128 | 0 | return $self->_parse_input( $irc, $who, $channel, $message, 'privmsg' ); | |||||||||||||||||||||||||||
| 129 | } | ||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||
| 131 | 0 | ▶ | sub _parse_input { | ||||||||||||||||||||||||||
|
Subroutine
_parse_input: not called CC=13 SCAR=52.0
| |||||||||||||||||||||||||||||
| 132 | 0 | my ( $self, $irc, $who, $channel, $message, $type ) = @_; | |||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||
| 134 | warn "Got input: [ who => $who, channel => $channel, " | ||||||||||||||||||||||||||||
| 135 | . "mesage => $message ]" | ||||||||||||||||||||||||||||
| 136 | 0 | ▶ | if $self->{debug}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||
| 138 | return PCI_EAT_NONE | ||||||||||||||||||||||||||||
| 139 | 0 | ▶ | unless exists $self->{listen_for_input}{ $type }; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||
| 141 | 0 | my $what; | |||||||||||||||||||||||||||
| 142 | 0 | ▶ | if ( $self->{addressed} and $type eq 'public' ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->{"addressed"} and $type eq "public"
MC/DC0%0/2
$self->{"addressed"} and $type eq "public"
$self->{"addressed"}
$type eq "public"
Truth table0%0/3
A and B
A= $self->{"addressed"}B= $type eq "public"
| |||||||||||||||||||||||||||||
| 143 | 0 | my $my_nick = $irc->nick_name(); | |||||||||||||||||||||||||||
| 144 | 0 | ($what) = $message =~ m/^\s*\Q$my_nick\E[\:\,\;\.]?\s*(.*)$/i; | |||||||||||||||||||||||||||
| 145 | } | ||||||||||||||||||||||||||||
| 146 | else { | ||||||||||||||||||||||||||||
| 147 | 0 | $what = $message; | |||||||||||||||||||||||||||
| 148 | } | ||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||
| 150 | 0 | ▶ | return PCI_EAT_NONE | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $what and $what =~ s/$self->{"trigger"}//
MC/DC0%0/2
defined $what and $what =~ s/$self->{"trigger"}//
defined $what
$what =~ s/$self->{"trigger"}//
Truth table0%0/3
A and B
A= defined $whatB= $what =~ s/$self->{"trigger"}//
| |||||||||||||||||||||||||||||
| 151 | unless defined $what and $what =~ s/$self->{trigger}//; | ||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||
| 153 | 0 | $what =~ s/^\s+|\s+$//; | |||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||
| 155 | 0 | ▶ | return PCI_EAT_NONE | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 156 | unless defined $message; | ||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||
| 158 | warn "Matched trigger: [ who => $who, channel => $channel, " | ||||||||||||||||||||||||||||
| 159 | . "what => $what ]" | ||||||||||||||||||||||||||||
| 160 | 0 | ▶ | if $self->{debug}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||
| 162 | 0 | ▶ | foreach my $ban_re ( @{ $self->{banned} || [] } ) { | ||||||||||||||||||||||||||
|
Condition0%0/2
$self->{'banned'} || []
MC/DC0%0/1
$self->{'banned'} || []
$self->{'banned'}
Truth table0%0/2
A
A= $self->{'banned'}
| |||||||||||||||||||||||||||||
| 163 | 0 | ▶ | return PCI_EAT_NONE | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 164 | if $who =~ /$ban_re/; | ||||||||||||||||||||||||||||
| 165 | } | ||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||
| 167 | 0 | $poe_kernel->post( $self->{_session_id} => _start_val => { | |||||||||||||||||||||||||||
| 168 | _who => $who, | ||||||||||||||||||||||||||||
| 169 | _what => $what, | ||||||||||||||||||||||||||||
| 170 | _channel => $channel, | ||||||||||||||||||||||||||||
| 171 | _message => $message, | ||||||||||||||||||||||||||||
| 172 | _type => $type, | ||||||||||||||||||||||||||||
| 173 | } | ||||||||||||||||||||||||||||
| 174 | ); | ||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||
| 176 | 0 | ▶ | return $self->{eat} ? PCI_EAT_ALL : PCI_EAT_NONE; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 177 | } | ||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||
| 179 | 0 | ▶ | sub _start_val { | ||||||||||||||||||||||||||
|
Subroutine
_start_val: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 180 | 0 | my ( $self, $args ) = @_[ OBJECT, ARG0 ]; | |||||||||||||||||||||||||||
| 181 | $self->{poco}->validate( { | ||||||||||||||||||||||||||||
| 182 | event => '_validated', | ||||||||||||||||||||||||||||
| 183 | uri => $args->{_what}, | ||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||
| 185 | 0 | %$args, | |||||||||||||||||||||||||||
| 186 | } | ||||||||||||||||||||||||||||
| 187 | ); | ||||||||||||||||||||||||||||
| 188 | } | ||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||
| 190 | 0 | ▶ | sub _validated { | ||||||||||||||||||||||||||
|
Subroutine
_validated: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||
| 191 | 0 | my ( $kernel, $self, $in_ref ) = @_[ KERNEL, OBJECT, ARG0 ]; | |||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||
| 193 | 0 | my $response_message; | |||||||||||||||||||||||||||
| 194 | 0 | ▶ | if ( $in_ref->{result} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 195 | 0 | $response_message = $self->_make_response( $in_ref ); | |||||||||||||||||||||||||||
| 196 | } | ||||||||||||||||||||||||||||
| 197 | else { | ||||||||||||||||||||||||||||
| 198 | 0 | $response_message = "Validator error: $in_ref->{request_error}"; | |||||||||||||||||||||||||||
| 199 | } | ||||||||||||||||||||||||||||
| 200 | |||||||||||||||||||||||||||||
| 201 | $self->{irc}->_send_event( $self->{response_event} => { | ||||||||||||||||||||||||||||
| 202 | result => $response_message, | ||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||
| 204 | 0 | map { $_ => $in_ref->{"_$_"} } | |||||||||||||||||||||||||||
| 205 | qw( who what channel message type ), | ||||||||||||||||||||||||||||
| 206 | } | ||||||||||||||||||||||||||||
| 207 | ); | ||||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||
| 209 | my $response_type = $in_ref->{_type} eq 'public' | ||||||||||||||||||||||||||||
| 210 | ? 'privmsg' | ||||||||||||||||||||||||||||
| 211 | 0 | ▶ | : $in_ref->{_type}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||
| 213 | my $where = $in_ref->{_type} eq 'public' | ||||||||||||||||||||||||||||
| 214 | ? $in_ref->{_channel} | ||||||||||||||||||||||||||||
| 215 | 0 | ▶ | : (split /!/, $in_ref->{_who})[0]; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||
| 217 | 0 | ▶ | if ( $self->{auto} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 218 | $kernel->post( $self->{irc} => | ||||||||||||||||||||||||||||
| 219 | 0 | $response_type => | |||||||||||||||||||||||||||
| 220 | $where => | ||||||||||||||||||||||||||||
| 221 | $response_message | ||||||||||||||||||||||||||||
| 222 | ); | ||||||||||||||||||||||||||||
| 223 | } | ||||||||||||||||||||||||||||
| 224 | |||||||||||||||||||||||||||||
| 225 | 0 | undef; | |||||||||||||||||||||||||||
| 226 | } | ||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||
| 228 | 0 | ▶ | sub _make_response { | ||||||||||||||||||||||||||
|
Subroutine
_make_response: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 229 | 0 | my ( $self, $in_ref ) = @_; | |||||||||||||||||||||||||||
| 230 | |||||||||||||||||||||||||||||
| 231 | my $response = $in_ref->{is_valid} | ||||||||||||||||||||||||||||
| 232 | ? $self->{valid_format} | ||||||||||||||||||||||||||||
| 233 | 0 | ▶ | : $self->{invalid_format}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||
| 235 | my %replacement_for = ( | ||||||||||||||||||||||||||||
| 236 | uri_short => $self->_shorten_uri_length( $in_ref->{uri} ), | ||||||||||||||||||||||||||||
| 237 | 0 | map { $_ => $in_ref->{ $_ } } | |||||||||||||||||||||||||||
| 238 | qw( uri num_errors refer_to_uri num_warnings ) | ||||||||||||||||||||||||||||
| 239 | ); | ||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||
| 241 | %replacement_for | ||||||||||||||||||||||||||||
| 242 | 0 | = map { $_ => $replacement_for{ $_ } } | |||||||||||||||||||||||||||
| 243 | 0 | grep { defined $replacement_for{ $_ } } | |||||||||||||||||||||||||||
| 244 | keys %replacement_for; | ||||||||||||||||||||||||||||
| 245 | |||||||||||||||||||||||||||||
| 246 | 0 | my $replacement_re = join '|', keys %replacement_for; | |||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||
| 248 | 0 | $response | |||||||||||||||||||||||||||
| 249 | =~ s/ \Q[:[\E ($replacement_re) \Q]:]\E /$replacement_for{ $1 }/gix; | ||||||||||||||||||||||||||||
| 250 | |||||||||||||||||||||||||||||
| 251 | 0 | return $response; | |||||||||||||||||||||||||||
| 252 | } | ||||||||||||||||||||||||||||
| 253 | |||||||||||||||||||||||||||||
| 254 | 0 | ▶ | sub _shorten_uri_length { | ||||||||||||||||||||||||||
|
Subroutine
_shorten_uri_length: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 255 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 256 | 0 | my $uri = shift; | |||||||||||||||||||||||||||
| 257 | 0 | $uri =~ s{ ^ (?: (?: ht | f )tps?:// (www\.)? | www\. )}{}xi; | |||||||||||||||||||||||||||
| 258 | 0 | $uri =~ s{ \. (?: s?html? | php | pl | asp | jsp | css | js ) $ }{}xi; | |||||||||||||||||||||||||||
| 259 | 0 | ▶ | if ( length $uri > 16 ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 260 | 0 | $uri = substr( $uri, 0, 8) . "..." . substr $uri, -5 ; | |||||||||||||||||||||||||||
| 261 | } | ||||||||||||||||||||||||||||
| 262 | 0 | return $uri; | |||||||||||||||||||||||||||
| 263 | } | ||||||||||||||||||||||||||||
| 264 | |||||||||||||||||||||||||||||
| 265 | 1 | 1; | |||||||||||||||||||||||||||
| 266 | |||||||||||||||||||||||||||||
| 267 | __END__ | ||||||||||||||||||||||||||||