| 1 | package CGI::apacheSSI; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | # use HTML::SimpleParse; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 2 | ▶ | use File::Spec::Functions; # catfile() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 2 | ▶ | use FindBin; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 2 | ▶ | use LWP::UserAgent; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 2 | ▶ | use HTTP::Response; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 2 | ▶ | use HTTP::Cookies; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 2 | ▶ | use URI; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 2 | ▶ | use Date::Format; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 2 | our $VERSION = '0.94'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 2 | our $DEBUG = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | sub import { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 2 | ▶ | my($class,%args) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
import: called CC=3 SCAR=14.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 2 | ▶ | return unless exists $args{'autotie'}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 0 | ▶ | $args{'filehandle'} = $args{'autotie'} =~ /::/ ? $args{'autotie'} : caller().'::'.$args{'autotie'}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 2 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 0 | my $self = tie(*{$args{'filehandle'}},$class,%args); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 0 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 2 | my($gmt,$loc,$lmod); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | # NOTE: check for escaped \( or \), what should it do? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 2 | our $L; # used to return the brackets count | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | our $RE_parens_2C = qr/ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | ( # g1, everything inside the brackets, incl brackets | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | \( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | ( (?: # g2, everything inside the brackets | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | (?{ $L = 1 }) # $L counts ('s inside pattern | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | (?: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | (?:"[^"\\]* (?: \\.[^"\\]* )* ") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | | (?:'[^'\\]* (?: \\.[^'\\]* )* ') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | | (?:`[^`\\]* (?: \\.[^`\\]* )* `) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | | (?:[^"'`)(]) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | | (?: \( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | (?{ local $L=$L+1; }) # new set of nested parens | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | | (?: \) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | (?{ local $L=$L-1; }) # close a set of nested parens | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | (?(?{ $L==0 })(?!)) # ...if there was no matching open paren... | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | )* | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | )* ) # end g2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | \) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | ) # end g1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 2 | /x; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 2 | our $RE_quote_dbl_NC = qr/(?:"[^"\\]* (?: \\.[^"\\]* )* ")/x; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 2 | our $RE_quote_single_NC = qr/(?:'[^'\\]* (?: \\.[^'\\]* )* ')/x; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 2 | our $RE_quote_backtick_NC = qr/(?:`[^`\\]* (?: \\.[^`\\]* )* `)/x; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 2 | our $RE_all_quote_NC = qr/$RE_quote_dbl_NC|$RE_quote_single_NC|$RE_quote_backtick_NC/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 2 | our $RE_all_no_quote_NC = qr/$RE_all_quote_NC|[^'"`]/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 2 | our $RE_all_no_paren_NC = qr/$RE_all_quote_NC|[^()'"`]/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 2 | our $RE_all_no_paren_noop_NC = qr/$RE_all_quote_NC | [^()'"`&\|] | &[^&] | \|[^\|]/x; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 2 | our $RE_single_quote_false_NC = qr/^ (?:\s*'')+\s* [']* $ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | |^ '? (?:\\')* $/x; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | # empty, or 1+ unspaced single quotes, trivially false | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | # pairs of empty single quotes, false | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | # alternating backslash-single quotes, false | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | # apache's own, special way of quoting strings | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 2 | our $RE_apache_expr_quote = qr/ (?:"(?:[^"\\]|[\\]+[^\\])*?") | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | |(?:'(?:[^'\\]|[\\]+[^\\])*?') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | |(?:`(?:[^`\\]|[\\]+[^\\])*?`) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | /x; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | # NOTE: quotes that would be openers which are immediately preceeded by \w are treated as \w | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | # NOTE: needs to be preceeded by \s or =, otherwise becomes part of token (parsing oddity with apache 2.2.22) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 2 | our $RE_apache_expr_quote_all = qr/ $RE_apache_expr_quote | [^'"`\s]/x; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 2 | our $RE_runaway = qr/ \s+ \w+['"`]\S*\s+[^'"`]+['"`]+ /x; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 2 | our $RE_token_NC = qr{[[:alpha:]]\S+? (?:\s+ $RE_apache_expr_quote_all*? )*? $RE_runaway? }x; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | sub new { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 18 | ▶ | my($class,%args) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=13 SCAR=26.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 18 | my $self = bless {}, $class; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 18 | $self->{'_handle'} = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 18 | my $script_name = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 18 | ▶ | if(exists $ENV{'SCRIPT_NAME'}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 0 | ($script_name) = $ENV{'SCRIPT_NAME'} =~ /([^\/]+)$/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 18 | tie $gmt, 'CGI::apacheSSI::Gmt', $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 18 | tie $loc, 'CGI::apacheSSI::Local', $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 18 | tie $lmod, 'CGI::apacheSSI::LMOD', $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 18 | ▶ | $ENV{'DOCUMENT_ROOT'} ||= ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$ENV{"DOCUMENT_ROOT"} ||= ""
MC/DC0%0/1
$ENV{"DOCUMENT_ROOT"} ||= ""
$ENV{"DOCUMENT_ROOT"}
Truth table50%1/2
A
A= $ENV{"DOCUMENT_ROOT"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | $self->{'_variables'} = { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | DOCUMENT_URI => ($args{'DOCUMENT_URI'} || $ENV{'SCRIPT_NAME'}), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | DATE_GMT => $gmt, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | DATE_LOCAL => $loc, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | LAST_MODIFIED => $lmod, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | DOCUMENT_NAME => ($args{'DOCUMENT_NAME'} || $script_name), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 18 | ▶ | DOCUMENT_ROOT => ($args{'DOCUMENT_ROOT'} || $ENV{DOCUMENT_ROOT}), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%6/9
$args{'DOCUMENT_URI'} || $ENV{'SCRIPT_NAME'}
$args{'DOCUMENT_NAME'} || $script_name
$args{'DOCUMENT_ROOT'} || $ENV{'DOCUMENT_ROOT'}
MC/DC50%1/2
$args{'DOCUMENT_URI'} || $ENV{'SCRIPT_NAME'}
$args{'DOCUMENT_URI'}
$ENV{'SCRIPT_NAME'}
MC/DC50%1/2
$args{'DOCUMENT_NAME'} || $script_name
$args{'DOCUMENT_NAME'}
$script_name
MC/DC50%1/2
$args{'DOCUMENT_ROOT'} || $ENV{'DOCUMENT_ROOT'}
$args{'DOCUMENT_ROOT'}
$ENV{'DOCUMENT_ROOT'}
Truth table66%2/3
A || B
A= $args{'DOCUMENT_URI'}B= $ENV{'SCRIPT_NAME'}
Truth table66%2/3
A || B
A= $args{'DOCUMENT_NAME'}B= $script_name
Truth table66%2/3
A || B
A= $args{'DOCUMENT_ROOT'}B= $ENV{'DOCUMENT_ROOT'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | $self->{'_config'} = { # NOTE: TODO: get these from apache config | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | errmsg => ($args{'errmsg'} || '[an error occurred while processing this directive]'), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | sizefmt => ($args{'sizefmt'} || 'abbrev'), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | timefmt => ($args{'timefmt'} || undef), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | SSIUndefinedEcho => ($args{'SSIUndefinedEcho'} || '(none)'), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 18 | ▶ | _verbose_errors => ($args{'_verbose_errors'} || 0) # NOTE: TODO: document this option | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition80%8/10
$args{'errmsg'} || '[an error occurred while processing this directive]'
$args{'sizefmt'} || 'abbrev'
$args{'timefmt'} || undef
$args{'SSIUndefinedEcho'} || '(none)'
$args{'_verbose_errors'} || 0
MC/DC100%1/1
$args{'errmsg'} || '[an error occurred while processing this directive]'
$args{'errmsg'}
MC/DC100%1/1
$args{'sizefmt'} || 'abbrev'
$args{'sizefmt'}
MC/DC100%1/1
$args{'timefmt'} || undef
$args{'timefmt'}
MC/DC0%0/1
$args{'SSIUndefinedEcho'} || '(none)'
$args{'SSIUndefinedEcho'}
MC/DC0%0/1
$args{'_verbose_errors'} || 0
$args{'_verbose_errors'}
Truth table100%2/2
A
A= $args{'errmsg'}
Truth table100%2/2
A
A= $args{'sizefmt'}
Truth table100%2/2
A
A= $args{'timefmt'}
Truth table50%1/2
A
A= $args{'SSIUndefinedEcho'}
Truth table50%1/2
A
A= $args{'_verbose_errors'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 18 | ▶ | $self->{_max_recursions} = $args{MAX_RECURSIONS} || 100; # no "infinite" loops | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$args{'MAX_RECURSIONS'} || 100
MC/DC100%1/1
$args{'MAX_RECURSIONS'} || 100
$args{'MAX_RECURSIONS'}
Truth table100%2/2
A
A= $args{'MAX_RECURSIONS'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 18 | $self->{_recursions} = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 18 | ▶ | $self->{_cookie_jar} = $args{COOKIE_JAR} || HTTP::Cookies->new(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$args{'COOKIE_JAR'} || 'HTTP::Cookies'->new
MC/DC0%0/2
$args{'COOKIE_JAR'} || 'HTTP::Cookies'->new
$args{'COOKIE_JAR'}
'HTTP::Cookies'->new
Truth table66%2/3
A || B
A= $args{'COOKIE_JAR'}B= 'HTTP::Cookies'->new
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 18 | $self->{'_in_if'} = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 18 | $self->{'_suspend'} = [0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 18 | $self->{'_seen_true'} = [1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 18 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | sub TIEHANDLE { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 1 | ▶ | my($class,%args) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
TIEHANDLE: called CC=3 SCAR=11.3
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 1 | my $self = $class->new(%args); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 1 | $self->{'_handle'} = do { local *STDOUT }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 1 | my $handle_to_tie = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 1 | ▶ | if($args{'filehandle'} !~ /::/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 1 | $handle_to_tie = caller().'::'.$args{'filehandle'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 0 | $handle_to_tie = $args{'filehandle'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 1 | ▶ | open($self->{'_handle'},'>&'.$handle_to_tie) or die "Failed to copy the filehandle ($handle_to_tie): $!"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 1 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | sub PRINT { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 2 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
PRINT: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 2 | print {$self->{'_handle'}} map { $self->process($_) } @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | sub PRINTF { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
PRINTF: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 0 | my $fmt = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 0 | printf {$self->{'_handle'}} $fmt, map { $self->process($_) } @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | sub CLOSE { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 1 | ▶ | my($self) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
CLOSE: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 1 | close $self->{'_handle'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | sub SSI_WARN { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 0 | ▶ | my($self,$msg) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
SSI_WARN: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 0 | warn ref($self)." warn: $msg\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | sub SSI_ERROR { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 3 | ▶ | (my $self, $@) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
SSI_ERROR: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 3 | warn ref($self)." error: $@\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 3 | return; # returning false here allows us to do one line error returns. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | sub SSI_ERROR_FLUSH { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 3 | ▶ | my($self,$msg) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
SSI_ERROR_FLUSH: called CC=3 SCAR=11.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 3 | ▶ | if ($msg) {$self->SSI_ERROR($msg);} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 3 | $msg=$@; # NOTE: DEBUG ONLY! | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 3 | undef $@; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 3 | ▶ | return "[SSI ERROR=[$msg]]" if $self->{'_config'}->{'_verbose_errors'}; # NOTE: DEBUG ONLY! | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 3 | return $self->{'_config'}->{'errmsg'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | # NOTE: "if" allows expr="myexpr1" expr="myexpr2" where myexpr2 overwrites myexpr1. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | sub process { # NOTE: -- FIXME -- this fails if we comment out the tokens.. ie <!-- <!--#if --> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | # NOTE: -- FIXME -- this should fail if we have any open quotes (ie, the --> doesnt magically close the tag.. in apache 2.2 at least) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 56 | ▶ | my($self,@shtml) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
process: called CC=4 SCAR=13.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 56 | my $processed = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | # NOTE: FIXME: would this be easier with a global replace s///ge ? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 56 | @shtml = split(m/(<!--\#$RE_token_NC-->)/sx, join '',@shtml); # this will slurp up anything inside quotes, single or double | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 56 | my $count=0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 56 | for my $token (@shtml) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 114 | ▶ | if($token =~ /^<!--\#($RE_token_NC)-->$/sx) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 54 | $processed .= $self->_process_ssi_text($1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 60 | ▶ | next if $self->_suspended; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 60 | $processed .= $token; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 56 | return $processed; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | sub _process_ssi_text { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 54 | ▶ | my($self,$text) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_process_ssi_text: called CC=6 SCAR=21.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | # what's the first \S+? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 54 | ▶ | if($text !~ s/^(\S+)\s*//) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 0 | { return $self->SSI_ERROR_FLUSH("failed to find method name at beginning of string: '$text'."); } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 54 | my $method = $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 54 | ▶ | if (! $self->can($method) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 0 | { return $self->SSI_ERROR_FLUSH("unknown directive \"$method\" in parsed doc."); } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | # are we suspended? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 54 | ▶ | return '' if($self->_suspended and $method !~ /^(?:if|else|elif|endif)\b/); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->_suspended and not $method =~ /^(?:if|else|elif|endif)\b/
MC/DC0%0/2
$self->_suspended and not $method =~ /^(?:if|else|elif|endif)\b/
$self->_suspended
not $method =~ /^(?:if|else|elif|endif)\b/
Truth table33%1/3
A and not(B)
A= $self->_suspendedB= not $method =~ /^(?:if|else|elif|endif)\b/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 54 | my $res = $self->$method( $self->parse_args($text, $method) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 54 | ▶ | if ($@) { return $self->SSI_ERROR_FLUSH();} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 54 | return $res; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | # many thanks to HTML::SimpleParse, with a couple of modifications | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | sub parse_args { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 54 | ▶ | my ($self, $str, $method) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
parse_args: called CC=10 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 54 | my @returns; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | # Make sure we start searching at the beginning of the string | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 54 | pos($str) = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 54 | while (1) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 110 | ▶ | next if $str =~ m/\G\s+/gc; # Get rid of leading whitespace | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 110 | ▶ | if ( $str =~ m/\G | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | ([\w.-]+)\s*=\s* # the key | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | (?: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | # ($RE_all_quote_NC) \s* # anything in quotes | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | ($RE_apache_expr_quote_all) \s* # anything in quotes | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | | # or | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | ([^\s>]*) \s* # anything else, without whitespace or > | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | )/gcx ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 56 | my ($key, $val) = ($1, $+); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | # ----- NOTE: if $key is not "expr" trim the quotes.. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | # ----- (apache evaluates differently depending on the type of quotes) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 56 | ▶ | if ($key ne "expr") {$val =~ s/^['"`]?(.*?)['"`]?$/$1/;} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | 56 | push @returns, $key, $val; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | } elsif ( $str =~ m,\G/?([\w.-]+)\s*,gc ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | 0 | push @returns, $1 , undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | 54 | ▶ | if ($str =~ m/\G(.+)/gc) # anything left over?? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | 0 | $self->SSI_ERROR("missing argument name for value to tag \"$method\" in"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | # NOTE: notice this is NOT a "return".. we want processing to continue normally | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | 54 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | # too many arguments for if element in | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | # else/endif/printenv directive does not take tags in | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | 54 | my %allowed_tag_count; # NOTE: this needs to be moved up | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | 54 | $allowed_tag_count{'if'}=["expr"]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | 54 | $allowed_tag_count{'else'}=[]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | 54 | ▶ | if (defined $allowed_tag_count{$method}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 0 | ▶ | if (@returns > 2 * @{ $allowed_tag_count{$method} }) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | 0 | ▶ | if (@{ $allowed_tag_count{$method} } == 0) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 0 | { $self->SSI_ERROR("\"$method\" directive does not take tags in");} | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | 0 | { $self->SSI_ERROR("too many arguments for \"$method\" element in");} | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | 0 | elsif (@returns < 2 * @{ $allowed_tag_count{$method} }) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | 0 | { $self->SSI_ERROR("missing arguments for directive \"$method\"");} # NOTE: fix this error message | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | 54 | return @returns; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | sub _interp_vars { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | 6 | ▶ | local $^W = 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_interp_vars: called CC=6 SCAR=33.3
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 6 | my($self,$text,$setcmd) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | # NOTE: var name in ${} MUST start with at least one \w | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | 6 | $text =~ s{ ((\\*) ((\\)|(\$)) (\{)?(\w (?(6)(.*)\}|(\w*)) )) } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | 0 | my ($all,$slashes, $slash,$dollar, $lbrak,$var)=($1,$2, $4,$5, $6,$7); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | 0 | $slashes .= $slash; # NOTE: this can be improved | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | 0 | ▶ | if ($lbrak) {chop $var}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | 0 | ▶ | if (! $setcmd) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | 0 | { chop($slashes); } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | 0 | ▶ | if ($dollar && ! $slashes) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$dollar and not $slashes
MC/DC0%0/2
$dollar and not $slashes
$dollar
not $slashes
Truth table0%0/3
A and not(B)
A= $dollarB= not $slashes
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | 0 | { $var = $self->_echo($var); } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | 0 | ▶ | $var = "{$var}" if ($lbrak) ; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | 0 | $var = $dollar.$var; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | 0 | $slashes.$var | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | }exg; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | 6 | return $text; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | # for internal use only - returns the thing passed in if it's not defined. echo() returns '' in that case. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | sub _echo { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | 0 | ▶ | my($self,$key,$var) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_echo: not called CC=7 SCAR=40.3
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | 0 | ▶ | $var = $key if @_ == 2; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | 0 | ▶ | if($var eq 'DATE_LOCAL') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | 0 | return $loc; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | } elsif($var eq 'DATE_GMT') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | 0 | return $gmt; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | } elsif($var eq 'LAST_MODIFIED') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | 0 | return $lmod; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | 0 | ▶ | return $self->{'_variables'}->{$var} if exists $self->{'_variables'}->{$var}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | 0 | ▶ | return $ENV{$var} if exists $ENV{$var}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | 0 | return ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | # ssi directive methods | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | sub config { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | 5 | ▶ | my($self,$type,$value) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
config: called CC=7 SCAR=23.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | 5 | ▶ | if($type =~ /^timefmt$/i) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | 3 | $self->{'_config'}->{'timefmt'} = $value; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | } elsif($type =~ /^sizefmt$/i) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | 1 | ▶ | if(lc $value eq 'abbrev') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | 0 | $self->{'_config'}->{'sizefmt'} = 'abbrev'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | } elsif(lc $value eq 'bytes') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | 1 | $self->{'_config'}->{'sizefmt'} = 'bytes'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | 0 | return $self->SSI_ERROR_FLUSH("value for sizefmt is '$value'. It must be 'abbrev' or 'bytes'."); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | } elsif($type =~ /^errmsg$/i) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | 1 | $self->{'_config'}->{'errmsg'} = $value; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | } elsif($type =~ /^_verbose_errors/i) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | 0 | $self->{'_config'}->{'_verbose_errors'} = $value; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | 0 | return $self->SSI_ERROR_FLUSH("arg to config is '$type'. It must be one of: 'timefmt', 'sizefmt', or 'errmsg'."); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | 5 | return ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | sub set { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | 6 | ▶ | my($self,%args) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | 6 | ▶ | if(scalar keys %args > 1) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | 3 | $self->{'_variables'}->{$args{'var'}} = $self->_interp_vars($args{'value'}, 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | } else { # var => value notation | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | 3 | my($var,$value) = %args; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | 3 | $self->{'_variables'}->{$var} = $self->_interp_vars($value, 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | 6 | return ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | sub escaped { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | 9 | ▶ | my ($t)=@_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
escaped: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | 9 | $t =~ s/\\\$/\$/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | 9 | return $t ; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | sub echo { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | 12 | ▶ | my($self,$key,$var) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
echo: called CC=9 SCAR=27.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | 12 | ▶ | $var = $key if @_ == 2; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | 12 | my $encoding; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | 12 | ▶ | if ($key eq 'encoding') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | 0 | $encoding = $var; # NOTE: TODO: handle encoding. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | 0 | ($key,$var) = @_[3,4]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | 0 | ▶ | $var = $key if (!$var); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | 12 | ▶ | if($var eq 'DATE_LOCAL') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | 1 | return $loc; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | } elsif($var eq 'DATE_GMT') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | 0 | return $gmt; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | } elsif($var eq 'LAST_MODIFIED') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | 2 | return $lmod; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | # it seems apache's "echo" command escapes out instances of "\$" to display just "$" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | 9 | ▶ | return &escaped($self->{'_variables'}->{$var}) if exists $self->{'_variables'}->{$var}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | 0 | ▶ | return &escaped($ENV{$var}) if exists $ENV{$var}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | 0 | return $self->{'_config'}->{'SSIUndefinedEcho'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | sub printenv { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | 0 | ▶ | return join "\n",map {"$_=$ENV{$_}"} keys %ENV; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
printenv: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | sub include { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | 45 | ▶ | $DEBUG and do { local $" = "','"; warn "DEBUG: include('@_')\n" }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
include: called CC=4 SCAR=15.5
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | 45 | my($self,$type,$filename) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | 45 | ▶ | if(lc $type eq 'file') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | 42 | return $self->_include_file($filename); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | } elsif(lc $type eq 'virtual') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | 3 | return $self->_include_virtual($filename); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | 0 | return $self->SSI_ERROR_FLUSH("arg to include is '$type'. It must be one of: 'file' or 'virtual'."); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | sub _include_file { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | 43 | ▶ | $DEBUG and do { local $" = "','"; warn "DEBUG: _include_file('@_')\n" }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_include_file: called CC=5 SCAR=17.4
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | 43 | my($self,$filename) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | # get the filename to open | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | 43 | ▶ | $filename = catfile($FindBin::Bin,$filename) unless -e $filename; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | # if we've reached MAX_RECURSIONS for this filename, warn and return the error | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | 43 | ▶ | if(++$self->{_recursions}->{$filename} >= $self->{_max_recursions}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | 1 | return $self->SSI_ERROR_FLUSH("the maximum number of 'include file' recursions has been exceeded for '$filename'."); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | # open the file, or warn and return an error | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | 42 | my $fh = do { local *STDIN }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | 42 | ▶ | open($fh,$filename) or do { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | 0 | return $self->SSI_ERROR_FLUSH("failed to open file ($filename): $!"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | # process the included file and return the result | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | 42 | return $self->process(join '',<$fh>); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | sub _include_virtual { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | 3 | ▶ | $DEBUG and do { local $" = "','"; warn "DEBUG: _include_virtual('@_')\n" }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_include_virtual: called CC=17 SCAR=36.8
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | 3 | my($self,$filename) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | # if this is a local file that we can just read, let's do that instead of getting it virtually | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | 3 | ▶ | if($filename =~ m|^/(.+)|) { # could be on the local server: absolute filename, relative to ., relative to $ENV{DOCUMENT_ROOT} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | 1 | my $file = $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | 1 | ▶ | if(-e '/'.$file) { # back to the original | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | 0 | $file = '/'.$file; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | } elsif(-e catfile($self->{'_variables'}->{'DOCUMENT_ROOT'},$file)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | 1 | $file = catfile($self->{'_variables'}->{'DOCUMENT_ROOT'},$file); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | } elsif(-e catfile($FindBin::Bin,$file)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | # $file = atfile($FindBin::Bin,$file); # <----- NOTE: is this a typo here?? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | 0 | $file = catfile($FindBin::Bin,$file); # fixing it just in case | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | 1 | ▶ | return $self->_include_file($file) if -e $file; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | # create the URI to get(), or warn and return the error | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | my $uri = eval { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | 2 | my $uri = URI->new($filename); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | 2 | ▶ | $uri->scheme($uri->scheme || ($ENV{HTTPS} ? 'https' : 'http')); # ?? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$uri->scheme || ($ENV{'HTTPS'} ? 'https' : 'http')
MC/DC0%0/2
$uri->scheme || ($ENV{'HTTPS'} ? 'https' : 'http')
$uri->scheme
($ENV{'HTTPS'} ? 'https' : 'http')
Truth table33%1/3
A || B
A= $uri->schemeB= ($ENV{'HTTPS'} ? 'https' : 'http')
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | 2 | ▶ | $uri->host($uri->host || $ENV{'HTTP_HOST'} || $ENV{'SERVER_NAME'} || 'localhost'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition37%3/8
$uri->host || $ENV{'HTTP_HOST'} || $ENV{'SERVER_NAME'} || 'localhost'
$uri->host or $ENV{"HTTP_HOST"} or $ENV{"SERVER_NAME"}
$uri->host or $ENV{"HTTP_HOST"}
MC/DC0%0/3
$uri->host || $ENV{'HTTP_HOST'} || $ENV{'SERVER_NAME'} || 'localhost'
$uri->host
$ENV{"HTTP_HOST"}
$ENV{"SERVER_NAME"}
Truth table25%1/4
A or B or C
A= $uri->hostB= $ENV{"HTTP_HOST"}C= $ENV{"SERVER_NAME"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | 2 | $uri; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | 2 | ▶ | } or do { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | 0 | return $self->SSI_ERROR_FLUSH("failed to create a URI based on '$filename'."); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | 2 | ▶ | if($@) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | 0 | return $self->SSI_ERROR_FLUSH("failed to create a URI based on '$filename'."); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | # get the content of the request | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | 2 | ▶ | $self->{_ua} ||= $self->_get_ua(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$self->{"_ua"} ||= $self->_get_ua
MC/DC0%0/2
$self->{"_ua"} ||= $self->_get_ua
$self->{"_ua"}
$self->_get_ua
Truth table33%1/3
A ||= B
A= $self->{"_ua"}B= $self->_get_ua
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | 2 | my $url = $uri->canonical; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | # have we reached MAX_RECURSIONS? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | 2 | ▶ | if(++$self->{_recursions}->{$url} >= $self->{_max_recursions}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | 0 | return $self->SSI_ERROR_FLUSH("the maximum number of 'include virtual' recursions has been exceeded for '$url'."); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | 2 | my $response = $self->{_ua}->get($url); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | # is it a success? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | 2 | ▶ | unless($response->is_success) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | 1 | return $self->SSI_ERROR_FLUSH("failed to get('$url'): ".$response->status_line."."); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | # process the included content and return the result | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | 1 | return $self->process($response->content); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | sub _get_ua { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | 3 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_get_ua: called CC=2 SCAR=7.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | 3 | my %conf = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | 3 | ▶ | $conf{agent} = $ENV{HTTP_USER_AGENT} if $ENV{HTTP_USER_AGENT}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | 3 | my $ua = LWP::UserAgent->new(%conf); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | 3 | $ua->cookie_jar($self->{_cookie_jar}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | 3 | return $ua; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | sub cookie_jar { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
cookie_jar: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | 0 | ▶ | if(my $jar = shift) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | 0 | $self->{_cookie_jar} = $jar; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | 0 | return $self->{_cookie_jar}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | sub exec { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | 2 | ▶ | my($self,$type,$filename) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
exec: called CC=3 SCAR=11.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | 2 | ▶ | if(lc $type eq 'cmd') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | 1 | return $self->_exec_cmd($filename); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | } elsif(lc $type eq 'cgi') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | 1 | return $self->_exec_cgi($filename); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | 0 | return $self->SSI_ERROR_FLUSH("arg to exec() is '$type'. It must be one of: 'cmd' or 'cgi'."); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | sub _exec_cmd { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | 1 | ▶ | my($self,$filename) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_exec_cmd: called CC=3 SCAR=12.3
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | # have we reached MAX_RECURSIONS? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | 1 | ▶ | if(++$self->{_recursions}->{$filename} >= $self->{_max_recursions}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | 0 | return $self->SSI_ERROR_FLUSH("the maximum number of 'exec cmd' recursions has been exceeded for '$filename'."); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | 1 | my $output = `$filename`; # security here is mighty bad. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | # was the command a success? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | 1 | ▶ | if($?) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | 0 | return $self->SSI_ERROR_FLUSH("`$filename` was not successful."); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | # process the output, and return the result | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | 1 | return $self->process($output); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | sub _exec_cgi { # no relative $filename allowed. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | 1 | ▶ | my($self,$filename) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_exec_cgi: called CC=11 SCAR=31.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | # have we reached MAX_RECURSIONS? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | 1 | ▶ | if(++$self->{_recursions}->{$filename} >= $self->{_max_recursions}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | 0 | return $self->SSI_ERROR_FLUSH("the maximum number of 'exec cgi' recursions has been exceeded for '$filename'."); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | # create the URI from the filename | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | my $uri = eval { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | 1 | my $uri = URI->new($filename); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | 1 | ▶ | $uri->scheme($uri->scheme || ($ENV{HTTPS} ? 'https' : 'http')); # ?? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$uri->scheme || ($ENV{'HTTPS'} ? 'https' : 'http')
MC/DC0%0/2
$uri->scheme || ($ENV{'HTTPS'} ? 'https' : 'http')
$uri->scheme
($ENV{'HTTPS'} ? 'https' : 'http')
Truth table33%1/3
A || B
A= $uri->schemeB= ($ENV{'HTTPS'} ? 'https' : 'http')
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | 1 | ▶ | $uri->host($uri->host || $ENV{'HTTP_HOST'} || $ENV{'SERVER_NAME'}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%2/6
$uri->host || $ENV{'HTTP_HOST'} || $ENV{'SERVER_NAME'}
$uri->host or $ENV{"HTTP_HOST"}
MC/DC0%0/3
$uri->host || $ENV{'HTTP_HOST'} || $ENV{'SERVER_NAME'}
$uri->host
$ENV{"HTTP_HOST"}
$ENV{'SERVER_NAME'}
Truth table25%1/4
A or B || C
A= $uri->hostB= $ENV{"HTTP_HOST"}C= $ENV{'SERVER_NAME'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | 1 | ▶ | $uri->query($uri->query || $ENV{'QUERY_STRING'}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$uri->query || $ENV{'QUERY_STRING'}
MC/DC0%0/2
$uri->query || $ENV{'QUERY_STRING'}
$uri->query
$ENV{'QUERY_STRING'}
Truth table33%1/3
A || B
A= $uri->queryB= $ENV{'QUERY_STRING'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | 1 | $uri; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | 1 | ▶ | } or do { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | 0 | return $self->SSI_ERROR_FLUSH("failed to create a URI from '$filename'."); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | 1 | ▶ | if($@) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | 0 | return $self->SSI_ERROR_FLUSH("failed to create a URI from '$filename'."); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 549 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 551 | # get the content | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | 1 | ▶ | $self->{_ua} ||= $self->_get_ua(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$self->{"_ua"} ||= $self->_get_ua
MC/DC0%0/2
$self->{"_ua"} ||= $self->_get_ua
$self->{"_ua"}
$self->_get_ua
Truth table33%1/3
A ||= B
A= $self->{"_ua"}B= $self->_get_ua
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 553 | 1 | my $url = $uri->canonical; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | 1 | my $response = $self->{_ua}->get($url); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | # success? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 557 | 1 | ▶ | unless($response->is_success) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | 0 | return $self->SSI_ERROR_FLUSH("failed to get('$filename')."); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 561 | # process the content and return the result | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | 1 | return $self->process($response->content); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 563 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 564 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 565 | sub flastmod { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 566 | 22 | ▶ | my($self,$type,$filename) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
flastmod: called CC=7 SCAR=20.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 568 | 22 | ▶ | if(lc $type eq 'file') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 569 | 21 | ▶ | $filename = catfile($FindBin::Bin,$filename) unless -e $filename; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 570 | } elsif(lc $type eq 'virtual') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 571 | 0 | ▶ | $filename = catfile($self->{'_variables'}->{'DOCUMENT_ROOT'},$filename) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 572 | unless $filename =~ /$self->{'_variables'}->{'DOCUMENT_ROOT'}/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 573 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 574 | 1 | return $self->SSI_ERROR_FLUSH("the first argument to flastmod is '$type'. It must be one of: 'file' or 'virtual'."); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 575 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 576 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 577 | 21 | ▶ | unless(-e $filename) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 578 | 0 | return $self->SSI_ERROR_FLUSH("flastmod failed to find '$filename'."); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 579 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 580 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 581 | 21 | my $flastmod = (stat $filename)[9]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 582 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 583 | 21 | ▶ | if($self->{'_config'}->{'timefmt'}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 584 | 3 | my @localtime = localtime($flastmod); # need this?? | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 585 | 3 | return Date::Format::strftime($self->{'_config'}->{'timefmt'},@localtime); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 586 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 587 | 18 | return scalar localtime($flastmod); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 588 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 589 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 590 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 591 | sub fsize { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 592 | 1 | ▶ | my($self,$type,$filename) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
fsize: called CC=13 SCAR=41.7
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 593 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 594 | 1 | ▶ | if(lc $type eq 'file') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 595 | 1 | ▶ | $filename = catfile($FindBin::Bin,$filename) unless -e $filename; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 596 | } elsif(lc $type eq 'virtual') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 597 | 0 | ▶ | $filename = catfile($ENV{'DOCUMENT_ROOT'},$filename) unless $filename =~ /$ENV{'DOCUMENT_ROOT'}/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 598 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 599 | 0 | return $self->SSI_ERROR_FLUSH("the first argument to fsize is '$type'. It must be one of: 'file' or 'virtual'."); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 600 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 601 | 1 | ▶ | unless(-e $filename) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 602 | 0 | return $self->SSI_ERROR_FLUSH("fsize failed to find '$filename'."); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 603 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 604 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 605 | 1 | my $fsize = (stat $filename)[7]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 606 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 607 | 1 | ▶ | if(lc $self->{'_config'}->{'sizefmt'} eq 'bytes') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 608 | 1 | ▶ | 1 while $fsize =~ s/^(\d+)(\d{3})/$1,$2/g; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 609 | 1 | return $fsize; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 610 | } else { # abbrev | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 611 | # gratefully lifted from Apache::SSI | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 612 | 0 | ▶ | return " 0k" unless $fsize; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 613 | 0 | ▶ | return " 1k" if $fsize < 1024; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 614 | 0 | ▶ | return sprintf("%4dk", ($fsize + 512)/1024) if $fsize < 1048576; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 615 | 0 | ▶ | return sprintf("%4.1fM", $fsize/1048576.0) if $fsize < 103809024; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 616 | 0 | ▶ | return sprintf("%4dM", ($fsize + 524288)/1048576) if $fsize < 1048576; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 617 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 618 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 619 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 620 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 621 | # if/elsif/else/endif and related methods | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 622 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 623 | # NOTE: anything calling _test should check $@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 624 | sub _test { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 625 | 0 | ▶ | my($self,$test) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_test: not called CC=50 SCAR=78.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 626 | 0 | my $quote; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 627 | 0 | my ($pound, $pounds); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 628 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 629 | 0 | $test =~ s/^(['"`])\s*(.*?)\s*(\1)$/$2/; # trim off surrounding (matching) quotes, and whitespace | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 630 | 0 | $quote= $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 631 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 632 | # trivial test returns: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 633 | 0 | ▶ | return 0 if $test =~ /$RE_single_quote_false_NC/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 634 | 0 | ▶ | return 1 if $test =~ /^["`]+$/; # 1+ double quotes or backticks, trivially true | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 635 | 0 | ▶ | return 1 if $test =~ /^[\s`'"]*?([`'"])?[\s]+?\1$/; # whitespace inside second set of quotes, trivially true | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 636 | 0 | ▶ | return 1 if $test =~ /^[\w]+$/; # bareword (alphanum) trivially true | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 637 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 638 | 0 | if (1) # ($test =~ m{^\(}) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 639 | { # need to do this otherwise it creates infinite loop for some reason | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 640 | 0 | ▶ | if ($test =~ m{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 641 | ((?:\!\s*)*) \s* # $1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 642 | ( # $2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 643 | $RE_parens_2C # ($3, $4) has 2 capture groups | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 644 | | | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 645 | (?:$RE_all_no_paren_noop_NC)* | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 646 | ) \s* | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 647 | (?: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 648 | (\&\& | \|\| )? \s* # $5 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 649 | (.*) # $6 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 650 | )? \s* | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 651 | }x) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 652 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 653 | # $1 is pound, $4 is inside the brackets, $5 is the op, $6 is the RHS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 654 | 0 | my $LHS=$2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 655 | 0 | my $LHS_parens=$4; # inside parentheses, does not include the parentheses | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 656 | 0 | my $OP=$5; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 657 | 0 | my $RHS=$6; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 658 | # expr="x == '\\x'" is split into: LHS=[ x == ] RHS=[ '\\x' ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 659 | 0 | $pounds=$pound=$1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 660 | 0 | $pound=~s/(?:\!\s*\!\s*)*//; # remove even # of !s, as these cancel out | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 661 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 662 | # if no op, and LHS and RHS, FAIL... because (x) b.. -- can be no LHS but RHS and noop | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 663 | # if no op and no $RHS, return pound != test(LHS) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 664 | # if op, and no RHS or no LHS, FAIL | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 665 | # if op, do op.. return [pound != test(LHS)] op [test(LHS)] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 666 | 0 | ▶ | if ($OP) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 667 | # LOGICAL COMPARISON && and || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 668 | # NOTE: && and || have equal precedence | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 669 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 670 | 0 | ▶ | if ($LHS=~/^\s*$/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 671 | 0 | return $self->SSI_ERROR("empty logical comparison in expr."); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 672 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 673 | 0 | ▶ | if ($RHS=~/^\s*$/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 674 | 0 | return $self->SSI_ERROR("empty logical comparison in expr."); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 675 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 676 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 677 | 0 | ▶ | if ($LHS_parens) {$LHS = $LHS_parens;} # needs to be done here, because of empty comparison checker | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 678 | 0 | $LHS = $self->_test($quote.$LHS.$quote); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 679 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 680 | 0 | ▶ | if ($@) {return;} # there were errors in the test | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 681 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 682 | 0 | ▶ | if ($pound) {$LHS = !$LHS;} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 683 | 0 | $RHS = $quote.$RHS.$quote; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 684 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 685 | 0 | ▶ | if ($OP eq "&&") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 686 | 0 | ▶ | { return ($LHS && $self->_test($RHS)); } # short circuits, faster | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$LHS && $self->_test($RHS)
MC/DC0%0/2
$LHS && $self->_test($RHS)
$LHS
$self->_test($RHS)
Truth table0%0/3
A && B
A= $LHSB= $self->_test($RHS)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 687 | else # ($OP eq "||") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 688 | 0 | ▶ | { return ($LHS || $self->_test($RHS)); } # short circuits, faster | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$LHS || $self->_test($RHS)
MC/DC0%0/2
$LHS || $self->_test($RHS)
$LHS
$self->_test($RHS)
Truth table0%0/3
A || B
A= $LHSB= $self->_test($RHS)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 689 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 690 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 691 | # NO OP | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 692 | 0 | ▶ | if ($LHS && $RHS) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
Condition0%0/3
$LHS and $RHS
MC/DC0%0/2
$LHS and $RHS
$LHS
$RHS
Truth table0%0/3
A and B
A= $LHSB= $RHS
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 693 | 0 | ▶ | if ($LHS_parens) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 694 | # return $self->SSI_ERROR("error in expression."); # NOTE: FIXME: improve this error msg.. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 695 | # return $self->SSI_ERROR("error in expression. LHS and RHS but no OP"); # NOTE: FIXME: improve this error msg.. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 696 | 0 | return $self->SSI_ERROR("error in expression. LHS [$LHS] and RHS [$RHS] but no OP"); # NOTE: FIXME: improve this error msg.. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 697 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 698 | 0 | $test = $LHS.$RHS; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 699 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 700 | elsif ($LHS) # brackets or balanced quotes | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 701 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 702 | 0 | ▶ | if ($LHS_parens) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 703 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 704 | 0 | $LHS = $self->_test($quote.$LHS_parens.$quote); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 705 | 0 | ▶ | if ($pound) {$LHS = !$LHS;} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 706 | 0 | return $LHS; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 707 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 708 | 0 | $test = $LHS; # NOTE: is this redundant? | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 709 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 710 | elsif ($RHS) # unbalanced quotes | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 711 | 0 | { $test = $RHS; } # NOTE: is this redundant? | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 712 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 713 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 714 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 715 | 0 | return $self->SSI_ERROR("unknown error in expression."); # SHOULD NOT REACH THIS | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 716 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 717 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 718 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 719 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 720 | #-------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 721 | # BAREWORD (no comparison sign) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 722 | 0 | ▶ | if ($test =~ /^(?:$RE_all_quote_NC|(?:[^=<>\/]|[\\]\/)*)$/) # BAREWORD | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 723 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 724 | 0 | ▶ | if ($test =~ /^(['])(.*?)(?:\1)$/) {$test=$2;} # need to trim surrounding single quotes | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 725 | 0 | ▶ | if ($test =~ /^$/) {return ($pound);} # no need to parse | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 726 | 0 | ▶ | if ($test =~ /^["]/) {return (! $pound);} # no need to parse | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 727 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 728 | 0 | my $interp_test = $self->_interp_vars($test); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 729 | 0 | my $RET = ($interp_test =~ /[^']+/); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 730 | 0 | ▶ | if ($interp_test ne $test) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 731 | { # var interpolation occurred, NOTE: apache deems only '' or empty to be false in this case. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 732 | 0 | $test = ($interp_test !~ /^$/) ; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 733 | 0 | ▶ | return (($pound) xor ($test)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/4
$pound ^^ $test
MC/DC0%0/2
$pound ^^ $test
$pound
$test
Truth table0%0/4
A ^^ B
A= $poundB= $test
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 734 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 735 | 0 | ▶ | return (($pound) xor ($RET)); # non empty string is true, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/4
$pound ^^ $RET
MC/DC0%0/2
$pound ^^ $RET
$pound
$RET
Truth table0%0/4
A ^^ B
A= $poundB= $RET
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 736 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 737 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 738 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 739 | #-------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 740 | # STRING COMPARISON >,<,==,!=,=~ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 741 | 0 | ▶ | if ($test =~ m{ \s*((?:$RE_all_quote_NC|[^<>=])*?)\s*([<>=!]=?)\s*([^<>=]*)\s* }x) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 742 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 743 | 0 | ▶ | if ($pounds) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 744 | 0 | { return $self->SSI_ERROR("invalid expression $quote$test$quote in file"); } # NOTE: FIXME | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 745 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 746 | 0 | my ($s1,$cmp,$s2)=($1, $2, $3); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 747 | 0 | ▶ | if ($s1=~/^\s*$/) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 748 | 0 | { return $self->SSI_ERROR("problem in REGEX. blank comparison \$s1"); } # NOTE: FIXME | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 749 | 0 | ▶ | if ($s2=~/^\s*$/) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 750 | 0 | { return $self->SSI_ERROR("problem in REGEX. blank comparison \$s2"); } # NOTE: FIXME | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 751 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 752 | 0 | ▶ | if ($s2 =~ m{^ \s* (?: (?:/\s*[^/]*) | // ) \s* $}x) # NOTE: what about escaped or stringed | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 753 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 754 | 0 | ▶ | if ($cmp =~ m/^==?$/) {return 1;} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 755 | 0 | elsif ($cmp =~ m/^!=$/) {return;} | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 756 | 0 | else { return $self->SSI_ERROR("Invalid expression $quote$test$quote in string comparison."); } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 757 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 758 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 759 | 0 | $s1=$self->_interp_vars($s1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 760 | 0 | ▶ | if ($s1 =~ /^(['"`])(.*?)(?:\1)$/) {$s1=$2;} # trim off surrounding (matching) quotes | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 761 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 762 | # REGEX | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 763 | 0 | ▶ | if ($s2 =~ m{^\s* / ((?:(?:(?:\\\\)*\\/) | [^/] )*) / (.*?)\s*$}x) # wrapped by /xx/ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 764 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 765 | 0 | ▶ | if ($2) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 766 | 0 | { return $self->SSI_ERROR("problem in REGEX. s2=[$s2] extra stuff=[$2]"); } # NOTE: FIXME | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 767 | 0 | $s2=qr/$1/; # regex s2 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 768 | 0 | $s2 = $self->_interp_vars($s2); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 769 | 0 | ▶ | if ($cmp =~ m/^==?$/) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 770 | 0 | { return ($s1 =~ m/$s2/);} | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 771 | elsif ($cmp eq "!=") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 772 | 0 | { return ($s1 !~ $s2); } # NOTE: FIXME!!! | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 773 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 774 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 775 | 0 | ▶ | if ($s2=~m|^[^\s/]+\s+/|) # unquoted, unescaped slash | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 776 | 0 | { return $self->SSI_ERROR("problem in REGEX unquoted slash. s2=[$s2]"); } # NOTE: FIXME | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 777 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 778 | 0 | $s2 = $self->_interp_vars($s2); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 779 | 0 | ▶ | if ($s2 =~ /^(['"])(.*?)(\1)$/) {$s2 = $2;} # trim off surrounding (matching) quotes | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 780 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 781 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 782 | 0 | my $ret; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 783 | 0 | $ret = $s1 cmp $s2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 784 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 785 | 0 | ▶ | if ($cmp =~ m/^==?$/) {$ret = ($ret eq 0);} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 6 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 786 | 0 | elsif ($cmp =~ m/^!=$/) {$ret = ($ret ne 0);} | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 787 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 788 | 0 | elsif ($cmp =~ m/^<$/) {$ret = ($ret lt 0);} | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 789 | 0 | elsif ($cmp =~ m/^<=$/) {$ret = ($ret le 0);} | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 790 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 791 | 0 | elsif ($cmp =~ m/^>$/) {$ret = ($ret gt 0);} | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 792 | 0 | elsif ($cmp =~ m/^>=$/) {$ret = ($ret ge 0);} | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 793 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 794 | 0 | else { return $self->SSI_ERROR("unknown comparison"); } # UNKNOWN COMPARISON -- should never reach this | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 795 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 796 | 0 | return $ret; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 797 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 798 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 799 | 0 | ▶ | if ($test =~ m{[^/]+\s+/}) # NOTE: UNFINISHED!! FIXME non empty unrecognized string that didnt fail | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 800 | 0 | { return $self->SSI_ERROR("error in expression, regex found in string"); } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 801 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 802 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 803 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 804 | 0 | return; # return false.. it seems none of the ops applied.. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 805 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 806 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 807 | sub _entering_if { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 808 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_entering_if: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 809 | 0 | $self->{'_in_if'}++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 810 | 0 | $self->{'_suspend'}->[$self->{'_in_if'}] = $self->{'_suspend'}->[$self->{'_in_if'} - 1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 811 | 0 | $self->{'_seen_true'}->[$self->{'_in_if'}] = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 812 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 813 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 814 | sub _seen_true { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 815 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_seen_true: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 816 | 0 | return $self->{'_seen_true'}->[$self->{'_in_if'}]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 817 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 818 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 819 | sub _suspended { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 820 | 114 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_suspended: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 821 | 114 | return $self->{'_suspend'}->[$self->{'_in_if'}]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 822 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 823 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 824 | sub _leaving_if { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 825 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_leaving_if: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 826 | 0 | ▶ | $self->{'_in_if'}-- if $self->{'_in_if'}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 827 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 828 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 829 | sub _true { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 830 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_true: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 831 | 0 | return $self->{'_seen_true'}->[$self->{'_in_if'}]++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 832 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 833 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 834 | sub _suspend { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 835 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_suspend: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 836 | 0 | $self->{'_suspend'}->[$self->{'_in_if'}]++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 837 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 838 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 839 | sub _resume { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 840 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_resume: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 841 | $self->{'_suspend'}->[$self->{'_in_if'}]-- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 842 | 0 | ▶ | if $self->{'_suspend'}->[$self->{'_in_if'}]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 843 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 844 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 845 | sub _in_if { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 846 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_in_if: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 847 | 0 | return $self->{'_in_if'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 848 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 849 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 850 | sub if { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 851 | 0 | ▶ | my($self,$expr,$test) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
if: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 852 | 0 | ▶ | $expr = $test if @_ == 3; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 853 | 0 | $self->_entering_if(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 854 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 855 | 0 | my $res=$self->_test($expr); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 856 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 857 | 0 | ▶ | if($@) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 858 | 0 | $self->_true(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 859 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 860 | } # any errors cause the expr to evaluate to true..?? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 861 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 862 | 0 | ▶ | if($res) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 863 | 0 | $self->_true(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 864 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 865 | 0 | $self->_suspend(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 866 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 867 | 0 | return ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 868 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 869 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 870 | sub elif { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 871 | 0 | ▶ | my($self,$expr,$test) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
elif: not called CC=10 SCAR=47.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 872 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 873 | 0 | ▶ | if (! $self->_in_if() ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 874 | 0 | $self->SSI_WARN("Incorrect use of elif ssi directive: no preceeding 'if'."); # NOTE: just a "warn" | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 875 | 0 | ▶ | $self->_suspend() unless $self->_suspended(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 876 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 877 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 878 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 879 | 0 | ▶ | if ($self->_seen_true()) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 880 | 0 | ▶ | $self->_suspend() unless $self->_suspended(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 881 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 882 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 883 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 884 | 0 | ▶ | $expr = $test if @_ == 3; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 885 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 886 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 887 | 0 | my $res= $self->_test($expr); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 888 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 889 | 0 | ▶ | if($@) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 890 | 0 | ▶ | $self->_suspend() unless $self->_suspended(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 891 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 892 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 893 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 894 | 0 | ▶ | if($res) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 895 | 0 | $self->_true(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 896 | 0 | $self->_resume(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 897 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 898 | 0 | ▶ | $self->_suspend() unless $self->_suspended(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 899 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 900 | 0 | return ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 901 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 902 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 903 | sub else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 904 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
else: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 905 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 906 | 0 | ▶ | if (! $self->_in_if() ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 907 | 0 | $self->SSI_WARN("Incorrect use of else ssi directive: no preceeding 'if'."); # NOTE: just a "warn" | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 908 | 0 | ▶ | $self->_suspend() unless $self->_suspended(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 909 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 910 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 911 | 0 | ▶ | if ($self->_seen_true()) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 912 | 0 | ▶ | $self->_suspend() unless $self->_suspended(); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 913 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 914 | 0 | $self->_resume(); } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 915 | 0 | return ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 916 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 917 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 918 | sub endif { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 919 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
endif: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 920 | 0 | ▶ | if (! $self->_in_if() ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 921 | 0 | $self->SSI_WARN("Incorrect use of endif ssi directive: no preceeding 'if'."); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 922 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 923 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 924 | 0 | { $self->_leaving_if(); } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 925 | 0 | ▶ | $self->_resume() if $self->_suspended(); # might be suspended even if not in "if" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 926 | 0 | return ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 927 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 928 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 929 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 930 | # if we're called like this, it means that we're to handle a CGI request ourselves. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 931 | # that means that we're to open the file and process the content, sending it to STDOUT | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 932 | # along with a standard HTTP content header | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 933 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 934 | 2 | ▶ | unless(caller) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 935 | 0 | goto &handler; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 936 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 937 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 938 | sub handler { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 939 | 0 | ▶ | eval "use CGI qw(:standard);"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
handler: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 940 | 0 | print header(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 941 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 942 | 0 | ▶ | unless(UNIVERSAL::isa(tied(*STDOUT),'CGI::apacheSSI')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 943 | 0 | tie *STDOUT, 'CGI::apacheSSI', filehandle => 'main::STDOUT'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 944 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 945 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 946 | 0 | my $filename = "$ENV{DOCUMENT_ROOT}$ENV{REQUEST_URI}"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 947 | 0 | ▶ | if(-f $filename) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 948 | 0 | ▶ | open my $fh, '<', $filename or die "Failed to open file ($filename): $!"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 949 | 0 | print <$fh>; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 950 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 951 | 0 | print "Failed to find file ($filename)."; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 952 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 953 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 954 | 0 | exit; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 955 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 956 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 957 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 958 | # packages for tie() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 959 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 960 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 961 | package CGI::apacheSSI::Gmt; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 962 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 963 | 18 | ▶ | sub TIESCALAR { bless [@_], shift() } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
TIESCALAR: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 964 | sub FETCH { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 965 | 18 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
FETCH: called CC=2 SCAR=8.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 966 | 18 | ▶ | if($self->[-1]->{'_config'}->{'timefmt'}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 967 | 0 | my @gt = gmtime; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 968 | 0 | return Date::Format::strftime($self->[-1]->{'_config'}->{'timefmt'},@gt); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 969 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 970 | 18 | return scalar gmtime; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 971 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 972 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 973 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 974 | package CGI::apacheSSI::Local; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 975 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 976 | 18 | ▶ | sub TIESCALAR { bless [@_], shift() } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
TIESCALAR: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 977 | sub FETCH { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 978 | 19 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
FETCH: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 979 | 19 | ▶ | if($self->[-1]->{'_config'}->{'timefmt'}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 980 | 1 | my @lt = localtime; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 981 | 1 | return Date::Format::strftime($self->[-1]->{'_config'}->{'timefmt'},@lt); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 982 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 983 | 18 | return scalar localtime; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 984 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 985 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 986 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 987 | package CGI::apacheSSI::LMOD; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 988 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 989 | 18 | ▶ | sub TIESCALAR { bless [@_], shift() } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
TIESCALAR: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 990 | sub FETCH { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 991 | 20 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
FETCH: called CC=3 SCAR=13.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 992 | 20 | ▶ | return $self->[-1]->flastmod('file', $ENV{'SCRIPT_FILENAME'} || $ENV{'PATH_TRANSLATED'} || ''); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition40%2/5
$ENV{'SCRIPT_FILENAME'} || $ENV{'PATH_TRANSLATED'} || ''
$ENV{"SCRIPT_FILENAME"} or $ENV{"PATH_TRANSLATED"}
MC/DC0%0/2
$ENV{'SCRIPT_FILENAME'} || $ENV{'PATH_TRANSLATED'} || ''
$ENV{"SCRIPT_FILENAME"}
$ENV{"PATH_TRANSLATED"}
Truth table33%1/3
A or B
A= $ENV{"SCRIPT_FILENAME"}B= $ENV{"PATH_TRANSLATED"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 993 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 994 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 995 | 2 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 996 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||