blib/lib/CGI/apacheSSI.pm

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