| 1 | # -*- perl -*- | ||||||||||||||||||||||||||||||||||||||||||||||
| 2 | # | ||||||||||||||||||||||||||||||||||||||||||||||
| 3 | # HTML::EP - A Perl based HTML extension. | ||||||||||||||||||||||||||||||||||||||||||||||
| 4 | # | ||||||||||||||||||||||||||||||||||||||||||||||
| 5 | # | ||||||||||||||||||||||||||||||||||||||||||||||
| 6 | # Copyright (C) 1998 Jochen Wiedmann | ||||||||||||||||||||||||||||||||||||||||||||||
| 7 | # Am Eisteich 9 | ||||||||||||||||||||||||||||||||||||||||||||||
| 8 | # 72555 Metzingen | ||||||||||||||||||||||||||||||||||||||||||||||
| 9 | # Germany | ||||||||||||||||||||||||||||||||||||||||||||||
| 10 | # | ||||||||||||||||||||||||||||||||||||||||||||||
| 11 | # Email: joe@ispsoft.de | ||||||||||||||||||||||||||||||||||||||||||||||
| 12 | # | ||||||||||||||||||||||||||||||||||||||||||||||
| 13 | # | ||||||||||||||||||||||||||||||||||||||||||||||
| 14 | # Portions Copyright (C) 1999 OnTV Pittsburgh, L.P. | ||||||||||||||||||||||||||||||||||||||||||||||
| 15 | # 123 University St. | ||||||||||||||||||||||||||||||||||||||||||||||
| 16 | # Pittsburgh, PA 15213 | ||||||||||||||||||||||||||||||||||||||||||||||
| 17 | # USA | ||||||||||||||||||||||||||||||||||||||||||||||
| 18 | # | ||||||||||||||||||||||||||||||||||||||||||||||
| 19 | # Phone: 1 412 681 5230 | ||||||||||||||||||||||||||||||||||||||||||||||
| 20 | # Developer: Jason McMullan <jmcc@ontv.com> | ||||||||||||||||||||||||||||||||||||||||||||||
| 21 | # Developer: Erin Glendenning <erg@ontv.com> | ||||||||||||||||||||||||||||||||||||||||||||||
| 22 | # | ||||||||||||||||||||||||||||||||||||||||||||||
| 23 | # | ||||||||||||||||||||||||||||||||||||||||||||||
| 24 | # All rights reserved. | ||||||||||||||||||||||||||||||||||||||||||||||
| 25 | # | ||||||||||||||||||||||||||||||||||||||||||||||
| 26 | # You may distribute this module under the terms of either | ||||||||||||||||||||||||||||||||||||||||||||||
| 27 | # the GNU General Public License or the Artistic License, as | ||||||||||||||||||||||||||||||||||||||||||||||
| 28 | # specified in the Perl README file. | ||||||||||||||||||||||||||||||||||||||||||||||
| 29 | # | ||||||||||||||||||||||||||||||||||||||||||||||
| 30 | ############################################################################ | ||||||||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 10 | require 5.005; | |||||||||||||||||||||||||||||||||||||||||||||
| 33 | 10 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 10 | ▶ | use CGI (); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 10 | ▶ | use Symbol (); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 10 | ▶ | use HTML::EP::Config (); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 10 | ▶ | use HTML::EP::Parser (); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||||||
| 41 | package HTML::EP; | ||||||||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 10 | $HTML::EP::VERSION = '0.2011'; | |||||||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 88 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=7 SCAR=21.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 88 | my $proto = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 48 | 88 | ▶ | my $self = (@_ == 1) ? {%{shift()}} : { @_ }; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 88 | $self->{'_ep_output'} = ''; | |||||||||||||||||||||||||||||||||||||||||||||
| 50 | 88 | $self->{'_ep_output_stack'} = []; | |||||||||||||||||||||||||||||||||||||||||||||
| 51 | 88 | ▶ | $self->{'_ep_config'} ||= $HTML::EP::Config::CONFIGURATION; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$self->{"_ep_config"} ||= $HTML::EP::Config::CONFIGURATION
MC/DC0%0/2
$self->{"_ep_config"} ||= $HTML::EP::Config::CONFIGURATION
$self->{"_ep_config"}
$HTML::EP::Config::CONFIGURATION
Truth table33%1/3
A ||= B
A= $self->{"_ep_config"}B= $HTML::EP::Config::CONFIGURATION
| |||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 88 | ▶ | $self->{'debug'} ||= 0; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->{"debug"} ||= 0
MC/DC0%0/1
$self->{"debug"} ||= 0
$self->{"debug"}
Truth table50%1/2
A
A= $self->{"debug"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 88 | ▶ | $self->{'cgi'} ||= (CGI->new() || die "Failed to create CGI object: $!"); | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition40%2/5
$self->{"cgi"} ||= "CGI"->new || die("Failed to create CGI object: $!")
'CGI'->new || die("Failed to create CGI object: $!")
MC/DC0%0/2
$self->{"cgi"} ||= "CGI"->new || die("Failed to create CGI object: $!")
$self->{"cgi"}
'CGI'->new
Truth table33%1/3
A ||= B
A= $self->{"cgi"}B= 'CGI'->new
| |||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 88 | ▶ | bless($self, (ref($proto) || $proto)); | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
ref $proto || $proto
MC/DC0%0/2
ref $proto || $proto
ref $proto
$proto
Truth table33%1/3
A || B
A= ref $protoB= $proto
| |||||||||||||||||||||||||||||||||||||||||||||||
| 55 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 86 | ▶ | sub Run { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Run: called CC=6 SCAR=18.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 86 | my($self, $template) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 59 | 86 | my $parser = HTML::EP::Parser->new(); | |||||||||||||||||||||||||||||||||||||||||||||
| 60 | 86 | my $r = $self->{'_ep_r'}; | |||||||||||||||||||||||||||||||||||||||||||||
| 61 | 86 | ▶ | $self->{'env'} ||= $r ? | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->{"env"} ||= $r ? {$r->cgi_env, "PATH_INFO", $r->uri} : \%ENV
MC/DC0%0/2
$self->{"env"} ||= $r ? {$r->cgi_env, "PATH_INFO", $r->uri} : \%ENV
$self->{"env"}
$r ? {$r->cgi_env, "PATH_INFO", $r->uri} : \%ENV
Truth table33%1/3
A ||= B
A= $self->{"env"}B= $r ? {$r->cgi_env, "PATH_INFO", $r->uri} : \%ENV
| |||||||||||||||||||||||||||||||||||||||||||||||
| 62 | { $r->cgi_env(), 'PATH_INFO' => $r->uri() } : \%ENV; | ||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 86 | ▶ | if ($template) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 84 | $parser->parse($template); | |||||||||||||||||||||||||||||||||||||||||||||
| 65 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 2 | ▶ | my $file = $self->{'env'}->{'PATH_TRANSLATED'} | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->{'env'}{'PATH_TRANSLATED'} || die('Missing server environment (PATH_TRANSLATED variable)')
MC/DC0%0/1
$self->{'env'}{'PATH_TRANSLATED'} || die('Missing server environment (PATH_TRANSLATED variable)')
$self->{'env'}{'PATH_TRANSLATED'}
Truth table50%1/2
A
A= $self->{'env'}{'PATH_TRANSLATED'}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 67 | || die "Missing server environment (PATH_TRANSLATED variable)"; | ||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 2 | my $fh = Symbol::gensym(); | |||||||||||||||||||||||||||||||||||||||||||||
| 69 | 2 | ▶ | open($fh, "<$file") || die "Failed to open $file: $!"; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 2 | $parser->parse_file($fh); | |||||||||||||||||||||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 86 | $parser->eof(); | |||||||||||||||||||||||||||||||||||||||||||||
| 73 | 86 | my $tokens = HTML::EP::Tokens->new('tokens' => $parser->{'_ep_tokens'}); | |||||||||||||||||||||||||||||||||||||||||||||
| 74 | 86 | $self->{'_ep_output'} = $self->ParseVars($self->TokenMarch($tokens)); | |||||||||||||||||||||||||||||||||||||||||||||
| 75 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 2 | ▶ | sub CgiRun { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
CgiRun: called CC=16 SCAR=42.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 2 | my($self, $path, $r) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 80 | 2 | my $cgi = $self->{'cgi'}; | |||||||||||||||||||||||||||||||||||||||||||||
| 81 | 2 | my $ok_templates = $self->{'_ep_config'}->{'ok_templates'}; | |||||||||||||||||||||||||||||||||||||||||||||
| 82 | 2 | local $| = 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 83 | 2 | my $output = eval { | |||||||||||||||||||||||||||||||||||||||||||||
| 84 | die "Access to $path forbidden; check ok_templates in ", | ||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 2 | ▶ | $INC{'HTML/EP/Config.pm'} | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$ok_templates and not $path =~ /$ok_templates/
MC/DC0%0/2
$ok_templates and not $path =~ /$ok_templates/
$ok_templates
not $path =~ /$ok_templates/
Truth table33%1/3
A and not(B)
A= $ok_templatesB= not $path =~ /$ok_templates/
| |||||||||||||||||||||||||||||||||||||||||||||||
| 86 | if $ok_templates && $path !~ /$ok_templates/; | ||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 2 | ▶ | $self->_ep_debug({}) if $cgi->param('debug'); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 2 | $self->Run(); | |||||||||||||||||||||||||||||||||||||||||||||
| 89 | }; | ||||||||||||||||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 2 | ▶ | if ($@) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 2 | ▶ | if ($@ =~ /_ep_exit, ignore/) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 0 | $output .= $self->ParseVars($self->{'_ep_output'}); | |||||||||||||||||||||||||||||||||||||||||||||
| 94 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 2 | my $errmsg; | |||||||||||||||||||||||||||||||||||||||||||||
| 96 | 2 | my $errstr = $@; | |||||||||||||||||||||||||||||||||||||||||||||
| 97 | my $errfile = $self->{_ep_err_type} ? | ||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 2 | ▶ | $self->{_ep_err_file_user} : $self->{_ep_err_file_system}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 2 | ▶ | if ($errfile) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 0 | ▶ | if ($errfile =~ /^\//) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 101 | my $derrfile = $r ? | ||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 0 | ▶ | $r->cgi_var('DOCUMENT_ROOT') : $ENV{'DOCUMENT_ROOT'} | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 103 | . $errfile; | ||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 0 | ▶ | if ($self->{'debug'}) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 105 | $self->print("Error type = " . $self->{_ep_err_type} . | ||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 0 | ", error file = $errfile" . | |||||||||||||||||||||||||||||||||||||||||||||
| 107 | ", derror file = $derrfile\n"); | ||||||||||||||||||||||||||||||||||||||||||||||
| 108 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 0 | ▶ | if (-f $derrfile) { $errfile = $derrfile } | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 110 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 0 | my $fh = Symbol::gensym(); | |||||||||||||||||||||||||||||||||||||||||||||
| 112 | 0 | ▶ | if (open($fh, "<$errfile")) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 0 | local $/ = undef; | |||||||||||||||||||||||||||||||||||||||||||||
| 114 | 0 | $errmsg = <$fh>; | |||||||||||||||||||||||||||||||||||||||||||||
| 115 | 0 | close($fh); | |||||||||||||||||||||||||||||||||||||||||||||
| 116 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 117 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 2 | ▶ | if (!$errmsg) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 119 | $errmsg = $self->{_ep_err_type} ? | ||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 2 | ▶ | $self->{_ep_err_msg_user} : $self->{_ep_err_msg_system}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 121 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 2 | return $self->SimpleError($errmsg, $errstr); | |||||||||||||||||||||||||||||||||||||||||||||
| 123 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 124 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 0 | ▶ | if (!$self->{_ep_stop}) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 127 | $self->print($cgi->header($self->SetCookies(), | ||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 0 | %{$self->{'_ep_headers'}}), $output); | |||||||||||||||||||||||||||||||||||||||||||||
| 129 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 130 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 32 | ▶ | sub FindEndTag { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
FindEndTag: called CC=7 SCAR=19.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 32 | my($self, $tokens, $tag) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 134 | 32 | my $level = 0; | |||||||||||||||||||||||||||||||||||||||||||||
| 135 | 32 | ▶ | while (defined(my $token = $tokens->Token())) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 83 | ▶ | if ($token->{'type'} eq 'S') { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 9 | ▶ | ++$level if $token->{'tag'} eq $tag; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 138 | } elsif ($token->{'type'} eq 'E') { | ||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 39 | ▶ | if ($token->{'tag'} eq $tag) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 37 | ▶ | return $tokens->First() unless $level--; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 141 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 142 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 143 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 0 | die "$tag without /$tag"; | |||||||||||||||||||||||||||||||||||||||||||||
| 145 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 15 | ▶ | sub AttrVal { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
AttrVal: called CC=4 SCAR=13.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 15 | my($self, $val, $tokens, $token, $parse) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 149 | 15 | ▶ | return $val if defined($val); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 12 | my $first = $tokens->First(); | |||||||||||||||||||||||||||||||||||||||||||||
| 151 | my $last = $self->FindEndTag($tokens, | ||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 12 | ▶ | ref($token) ? $token->{'tag'} : $token); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 12 | my $output = $self->TokenMarch($tokens->Clone($first, $last-1)); | |||||||||||||||||||||||||||||||||||||||||||||
| 154 | 12 | ▶ | $parse ? $self->ParseVars($output) : $output; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 155 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 155 | ▶ | sub ParseAttr { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ParseAttr: called CC=5 SCAR=16.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 155 | my $self = shift; my $attr = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 159 | 155 | my $parsed_attr = {}; | |||||||||||||||||||||||||||||||||||||||||||||
| 160 | 155 | ▶ | while (my($var, $val) = each %$attr) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 187 | ▶ | if ($val =~ /\$\_\W/) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 49 | $_ = $self; | |||||||||||||||||||||||||||||||||||||||||||||
| 163 | 49 | $parsed_attr->{$var} = eval $val; | |||||||||||||||||||||||||||||||||||||||||||||
| 164 | 49 | ▶ | die $@ if $@; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 165 | } elsif ($val =~ /\$/) { | ||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 34 | $parsed_attr->{$var} = $self->ParseVars($val); | |||||||||||||||||||||||||||||||||||||||||||||
| 167 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 104 | $parsed_attr->{$var} = $val; | |||||||||||||||||||||||||||||||||||||||||||||
| 169 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 170 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 155 | $parsed_attr; | |||||||||||||||||||||||||||||||||||||||||||||
| 172 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 75 | ▶ | sub RepeatedTokenMarch { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
RepeatedTokenMarch: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 75 | my $self = shift; my $tokens = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 176 | 75 | my $first = $tokens->First(); | |||||||||||||||||||||||||||||||||||||||||||||
| 177 | 75 | my $last = $tokens->Last(); | |||||||||||||||||||||||||||||||||||||||||||||
| 178 | 75 | my $res = $self->TokenMarch($tokens); | |||||||||||||||||||||||||||||||||||||||||||||
| 179 | 75 | $tokens->First($first); | |||||||||||||||||||||||||||||||||||||||||||||
| 180 | 75 | $tokens->Last($last); | |||||||||||||||||||||||||||||||||||||||||||||
| 181 | 75 | $res; | |||||||||||||||||||||||||||||||||||||||||||||
| 182 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 232 | ▶ | sub TokenMarch { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
TokenMarch: called CC=9 SCAR=24.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 232 | my($self, $tokens) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 185 | 232 | my $debug = $self->{'debug'}; | |||||||||||||||||||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 232 | push(@{$self->{'_ep_output_stack'}}, $self->{'_ep_output'}); | |||||||||||||||||||||||||||||||||||||||||||||
| 188 | 232 | $self->{'_ep_output'} = ''; | |||||||||||||||||||||||||||||||||||||||||||||
| 189 | 232 | ▶ | $self->print("TokenMarch: From ", $tokens->First(), " to ", | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 190 | $tokens->Last(), ".\n") if $debug >= 2; | ||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 232 | ▶ | while (defined(my $token = $tokens->Token())) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 345 | my $type = $token->{'type'}; | |||||||||||||||||||||||||||||||||||||||||||||
| 193 | 345 | my $res; | |||||||||||||||||||||||||||||||||||||||||||||
| 194 | 345 | ▶ | if ($type eq 'T') { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 210 | $res = $token->{'text'}; | |||||||||||||||||||||||||||||||||||||||||||||
| 196 | } elsif ($token->{'type'} eq 'S') { | ||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 129 | my $method = "_$token->{'tag'}"; | |||||||||||||||||||||||||||||||||||||||||||||
| 198 | 129 | my $attr = $token->{'attr'}; | |||||||||||||||||||||||||||||||||||||||||||||
| 199 | 129 | $method =~ s/\-/_/g; | |||||||||||||||||||||||||||||||||||||||||||||
| 200 | 129 | $res = $self->$method($self->ParseAttr($attr), $tokens, $token); | |||||||||||||||||||||||||||||||||||||||||||||
| 201 | 121 | ▶ | if (!defined($res)) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 202 | # Upwards compatibility: If the method returned undef, then | ||||||||||||||||||||||||||||||||||||||||||||||
| 203 | # it is a multiline tag in the sense of EP1. We've got to | ||||||||||||||||||||||||||||||||||||||||||||||
| 204 | # collect all lines until a matching /$tag and evaluate it. | ||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 0 | my $def = delete $tokens->{'default'}; | |||||||||||||||||||||||||||||||||||||||||||||
| 206 | 0 | my $first = $tokens->First(); | |||||||||||||||||||||||||||||||||||||||||||||
| 207 | 0 | my $last = $self->FindEndTag($tokens, $token->{'tag'}); | |||||||||||||||||||||||||||||||||||||||||||||
| 208 | 0 | my $t = $tokens->Clone($first, $last-1); | |||||||||||||||||||||||||||||||||||||||||||||
| 209 | 0 | $attr->{$def} = $self->TokenMarch($t); | |||||||||||||||||||||||||||||||||||||||||||||
| 210 | 0 | $res = $self->$method($attr, $tokens); | |||||||||||||||||||||||||||||||||||||||||||||
| 211 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 212 | } elsif ($token->{'type'} eq 'I') { | ||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 6 | $res = $self->RepeatedTokenMarch($token->{'tokens'}); | |||||||||||||||||||||||||||||||||||||||||||||
| 214 | } elsif ($token->{'type'} eq 'E') { | ||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 0 | die "Unexpected end tag: /$token->{'tag'} without $token->{'tag'}"; | |||||||||||||||||||||||||||||||||||||||||||||
| 216 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 0 | die "Unknown token type $self->{'type'}"; | |||||||||||||||||||||||||||||||||||||||||||||
| 218 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 337 | $self->{'_ep_output'} .= $res; | |||||||||||||||||||||||||||||||||||||||||||||
| 220 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 224 | my $result = $self->{'_ep_output'}; | |||||||||||||||||||||||||||||||||||||||||||||
| 222 | 224 | ▶ | $self->print("TokenMarch: Returning $result.\n") if $debug >= 2; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 224 | $self->{'_ep_output'} = pop(@{$self->{'_ep_output_stack'}}); | |||||||||||||||||||||||||||||||||||||||||||||
| 224 | 224 | $result; | |||||||||||||||||||||||||||||||||||||||||||||
| 225 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 0 | ▶ | sub WarnHandler { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
WarnHandler: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 0 | my $msg = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 232 | 0 | ▶ | die $msg unless defined($^S); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 0 | print STDERR $msg; | |||||||||||||||||||||||||||||||||||||||||||||
| 234 | 0 | ▶ | print STDERR "\n" unless $msg =~ /\n$/; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 235 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||||||||||||||||||||
| 238 | 2 | ▶ | sub SimpleError { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
SimpleError: called CC=8 SCAR=22.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 239 | 2 | my($self, $template, $errmsg, $admin) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 240 | 2 | my $r; | |||||||||||||||||||||||||||||||||||||||||||||
| 241 | 2 | ▶ | $r = $self->{'_ep_r'} if $self && ref($self); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self and ref $self
MC/DC0%0/2
$self and ref $self
$self
ref $self
Truth table33%1/3
A and B
A= $selfB= ref $self
| |||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 2 | ▶ | $admin ||= ($r ? $r->cgi_var('SERVER_ADMIN') : $ENV{'SERVER_ADMIN'}); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$admin ||= $r ? $r->cgi_var("SERVER_ADMIN") : $ENV{"SERVER_ADMIN"}
MC/DC0%0/2
$admin ||= $r ? $r->cgi_var("SERVER_ADMIN") : $ENV{"SERVER_ADMIN"}
$admin
$r ? $r->cgi_var("SERVER_ADMIN") : $ENV{"SERVER_ADMIN"}
Truth table33%1/3
A ||= B
A= $adminB= $r ? $r->cgi_var("SERVER_ADMIN") : $ENV{"SERVER_ADMIN"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 2 | ▶ | $admin = $admin ? "<A HREF=\"mailto:$admin\">Webmaster</A>" : 'Webmaster'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 2 | my $vars = { errmsg => $errmsg, admin => $admin }; | |||||||||||||||||||||||||||||||||||||||||||||
| 245 | |||||||||||||||||||||||||||||||||||||||||||||||
| 246 | 2 | ▶ | if (!$template) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 247 | 1 | $template = <<'END_OF_HTML'; | |||||||||||||||||||||||||||||||||||||||||||||
| 248 | <HTML><HEAD><TITLE>Fatal internal error</TITLE></HEAD> | ||||||||||||||||||||||||||||||||||||||||||||||
| 249 | <BODY><H1>Fatal internal error</H1> | ||||||||||||||||||||||||||||||||||||||||||||||
| 250 | <P>An internal error occurred. The error message is:</P> | ||||||||||||||||||||||||||||||||||||||||||||||
| 251 | <PRE> | ||||||||||||||||||||||||||||||||||||||||||||||
| 252 | $errmsg$. | ||||||||||||||||||||||||||||||||||||||||||||||
| 253 | </PRE> | ||||||||||||||||||||||||||||||||||||||||||||||
| 254 | <P>Please contact the $admin$ and tell him URL, time and error message.</P> | ||||||||||||||||||||||||||||||||||||||||||||||
| 255 | <P>We apologize for any inconvenience, please try again later.</P> | ||||||||||||||||||||||||||||||||||||||||||||||
| 256 | <BR><BR><BR> | ||||||||||||||||||||||||||||||||||||||||||||||
| 257 | <P>Yours sincerely</P> | ||||||||||||||||||||||||||||||||||||||||||||||
| 258 | </BODY></HTML> | ||||||||||||||||||||||||||||||||||||||||||||||
| 259 | END_OF_HTML | ||||||||||||||||||||||||||||||||||||||||||||||
| 260 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 261 | |||||||||||||||||||||||||||||||||||||||||||||||
| 262 | 2 | $template =~ s/\$(\w+)\$/$vars->{$1}/g; | |||||||||||||||||||||||||||||||||||||||||||||
| 263 | 2 | ▶ | if ($r) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 264 | 0 | $r->print($self->{'cgi'}->header('-type' => 'text/html'), $template); | |||||||||||||||||||||||||||||||||||||||||||||
| 265 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 2 | print("content-type: text/html\n\n", $template); | |||||||||||||||||||||||||||||||||||||||||||||
| 267 | 2 | exit 0; | |||||||||||||||||||||||||||||||||||||||||||||
| 268 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 269 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 270 | |||||||||||||||||||||||||||||||||||||||||||||||
| 271 | 0 | ▶ | sub print ($;@) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
print: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 272 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 273 | 0 | ▶ | $self->{_ep_r} ? $self->{_ep_r}->print(@_) : print @_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 274 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 275 | |||||||||||||||||||||||||||||||||||||||||||||||
| 276 | 0 | ▶ | sub printf { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
printf: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 277 | 0 | my($self, $format, @args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 278 | 0 | $self->print(sprintf($format, @args)); | |||||||||||||||||||||||||||||||||||||||||||||
| 279 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 280 | |||||||||||||||||||||||||||||||||||||||||||||||
| 281 | 192 | ▶ | sub escapeHTML { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
escapeHTML: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 282 | 192 | my $self = shift; my $str = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 283 | 192 | $str =~ s/&/&/g; | |||||||||||||||||||||||||||||||||||||||||||||
| 284 | 192 | $str =~ s/\"/"/g; | |||||||||||||||||||||||||||||||||||||||||||||
| 285 | 192 | $str =~ s/>/>/g; | |||||||||||||||||||||||||||||||||||||||||||||
| 286 | 192 | $str =~ s/</</g; | |||||||||||||||||||||||||||||||||||||||||||||
| 287 | 192 | $str =~ s/\$/$/g; | |||||||||||||||||||||||||||||||||||||||||||||
| 288 | 192 | $str; | |||||||||||||||||||||||||||||||||||||||||||||
| 289 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 290 | |||||||||||||||||||||||||||||||||||||||||||||||
| 291 | 208 | ▶ | sub FindVar { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
FindVar: called CC=7 SCAR=20.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 292 | 208 | my($self, $var, $subvar) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 293 | 208 | ▶ | if ($var eq 'cgi') { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 294 | 0 | $subvar =~ s/\-\>//; | |||||||||||||||||||||||||||||||||||||||||||||
| 295 | 0 | return $self->{'cgi'}->param($subvar); | |||||||||||||||||||||||||||||||||||||||||||||
| 296 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 297 | |||||||||||||||||||||||||||||||||||||||||||||||
| 298 | 208 | $var = $self->{$var}; | |||||||||||||||||||||||||||||||||||||||||||||
| 299 | 208 | ▶ | while ($subvar && $subvar =~ /^\-\>(\w+)(.*)/) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$subvar and $subvar =~ /^\-\>(\w+)(.*)/
MC/DC50%1/2
$subvar and $subvar =~ /^\-\>(\w+)(.*)/
$subvar
$subvar =~ /^\-\>(\w+)(.*)/
Truth table66%2/3
A and B
A= $subvarB= $subvar =~ /^\-\>(\w+)(.*)/
| |||||||||||||||||||||||||||||||||||||||||||||||
| 300 | 31 | ▶ | return '' unless ref $var; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 301 | 31 | my $v = $1; | |||||||||||||||||||||||||||||||||||||||||||||
| 302 | 31 | $subvar = $2; | |||||||||||||||||||||||||||||||||||||||||||||
| 303 | 31 | ▶ | if ($v =~ /^\d+$/) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 304 | 4 | $var = $var->[$v]; | |||||||||||||||||||||||||||||||||||||||||||||
| 305 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 306 | 27 | $var = $var->{$v}; | |||||||||||||||||||||||||||||||||||||||||||||
| 307 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 308 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 309 | 208 | ▶ | defined $var ? $var : ''; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 310 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 311 | |||||||||||||||||||||||||||||||||||||||||||||||
| 312 | 207 | ▶ | sub ParseVar { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ParseVar: called CC=12 SCAR=26.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 313 | 207 | my($self, $type, $var, $subvar) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 314 | 207 | my $func; | |||||||||||||||||||||||||||||||||||||||||||||
| 315 | |||||||||||||||||||||||||||||||||||||||||||||||
| 316 | 207 | ▶ | if ($type && $type eq '&') { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$type and $type eq "&"
MC/DC100%2/2
$type and $type eq "&"
$type
$type eq "&"
Truth table100%3/3
A and B
A= $typeB= $type eq "&"
| |||||||||||||||||||||||||||||||||||||||||||||||
| 317 | # Custom format | ||||||||||||||||||||||||||||||||||||||||||||||
| 318 | $func = exists($self->{'_ep_custom_formats'}->{$var}) ? | ||||||||||||||||||||||||||||||||||||||||||||||
| 319 | 9 | ▶ | $self->{'_ep_custom_formats'}->{$var} : "_format_$var"; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 320 | |||||||||||||||||||||||||||||||||||||||||||||||
| 321 | # First part of subvar becomes var | ||||||||||||||||||||||||||||||||||||||||||||||
| 322 | 9 | ▶ | if ($subvar && $subvar =~ /^\-\>(\w+)(.*)/) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$subvar and $subvar =~ /^\-\>(\w+)(.*)/
MC/DC0%0/2
$subvar and $subvar =~ /^\-\>(\w+)(.*)/
$subvar
$subvar =~ /^\-\>(\w+)(.*)/
Truth table33%1/3
A and B
A= $subvarB= $subvar =~ /^\-\>(\w+)(.*)/
| |||||||||||||||||||||||||||||||||||||||||||||||
| 323 | 9 | $var = $1; | |||||||||||||||||||||||||||||||||||||||||||||
| 324 | 9 | $subvar = $2; | |||||||||||||||||||||||||||||||||||||||||||||
| 325 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 326 | 0 | $var = ''; | |||||||||||||||||||||||||||||||||||||||||||||
| 327 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 328 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 329 | |||||||||||||||||||||||||||||||||||||||||||||||
| 330 | 207 | $var = FindVar($self, $var, $subvar); | |||||||||||||||||||||||||||||||||||||||||||||
| 331 | |||||||||||||||||||||||||||||||||||||||||||||||
| 332 | 207 | ▶ | if (!$type || $type eq '%') { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
Condition100%3/3
not $type or $type eq "%"
MC/DC100%2/2
not $type or $type eq "%"
not $type
$type eq "%"
Truth table100%3/3
not(A) or B
A= not $typeB= $type eq "%"
| |||||||||||||||||||||||||||||||||||||||||||||||
| 333 | 191 | $var = $self->escapeHTML($var); | |||||||||||||||||||||||||||||||||||||||||||||
| 334 | } elsif ($type eq '#') { | ||||||||||||||||||||||||||||||||||||||||||||||
| 335 | 3 | $var = CGI->escape($var); | |||||||||||||||||||||||||||||||||||||||||||||
| 336 | } elsif ($type eq '~') { | ||||||||||||||||||||||||||||||||||||||||||||||
| 337 | 0 | ▶ | my $dbh = $self->{'dbh'} || die "Not connected"; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->{'dbh'} || die('Not connected')
MC/DC0%0/1
$self->{'dbh'} || die('Not connected')
$self->{'dbh'}
Truth table0%0/2
A
A= $self->{'dbh'}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 338 | 0 | $var = $dbh->quote($var); | |||||||||||||||||||||||||||||||||||||||||||||
| 339 | } elsif ($func) { | ||||||||||||||||||||||||||||||||||||||||||||||
| 340 | 9 | $var = $self->$func($var); | |||||||||||||||||||||||||||||||||||||||||||||
| 341 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 342 | |||||||||||||||||||||||||||||||||||||||||||||||
| 343 | 207 | $var; | |||||||||||||||||||||||||||||||||||||||||||||
| 344 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 345 | |||||||||||||||||||||||||||||||||||||||||||||||
| 346 | 208 | ▶ | sub ParseVars ($$) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ParseVars: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 347 | 208 | my($self, $str) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 348 | 208 | $str =~ s/\$([\&\@\#\~\%]?)(\w+)((?:\-\>\w+)*)\$/$self->ParseVar($1,$2,$3)/eg; | |||||||||||||||||||||||||||||||||||||||||||||
| 349 | 208 | $str; | |||||||||||||||||||||||||||||||||||||||||||||
| 350 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 351 | |||||||||||||||||||||||||||||||||||||||||||||||
| 352 | |||||||||||||||||||||||||||||||||||||||||||||||
| 353 | |||||||||||||||||||||||||||||||||||||||||||||||
| 354 | # For debugging | ||||||||||||||||||||||||||||||||||||||||||||||
| 355 | 0 | ▶ | sub Dump { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Dump: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 356 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 357 | 0 | require Data::Dumper; | |||||||||||||||||||||||||||||||||||||||||||||
| 358 | 0 | Data::Dumper->new([@_])->Indent(1)->Terse(1)->Dump(); | |||||||||||||||||||||||||||||||||||||||||||||
| 359 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 360 | |||||||||||||||||||||||||||||||||||||||||||||||
| 361 | 0 | ▶ | sub SetCookies { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
SetCookies: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 362 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 363 | 0 | my @cookies = values %{$self->{'_ep_cookies'}}; | |||||||||||||||||||||||||||||||||||||||||||||
| 364 | 0 | ▶ | return () unless @cookies; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 365 | print "Setting cookies:\n", $self->Dump(\@cookies), "\n" | ||||||||||||||||||||||||||||||||||||||||||||||
| 366 | 0 | ▶ | if $self->{'debug'}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 367 | 0 | ('-cookie' => \@cookies); | |||||||||||||||||||||||||||||||||||||||||||||
| 368 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 369 | |||||||||||||||||||||||||||||||||||||||||||||||
| 370 | |||||||||||||||||||||||||||||||||||||||||||||||
| 371 | |||||||||||||||||||||||||||||||||||||||||||||||
| 372 | 83 | ▶ | sub EvalIf { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
EvalIf: called CC=18 SCAR=29.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 373 | 83 | my($self, $tag, $attr) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 374 | 83 | my $debug = $self->{'debug'}; | |||||||||||||||||||||||||||||||||||||||||||||
| 375 | 83 | ▶ | if (exists($attr->{'eval'})) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 376 | 55 | ▶ | $self->print("$tag: Evaluating $attr->{'eval'}\n") if $debug; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 377 | 55 | return $attr->{'eval'}; | |||||||||||||||||||||||||||||||||||||||||||||
| 378 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 379 | 28 | ▶ | if (exists($attr->{'neval'})) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 380 | 2 | ▶ | $self->print("$tag: Evaluating ! $attr->{'neval'}\n") if $debug; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 381 | 2 | return !$attr->{'neval'}; | |||||||||||||||||||||||||||||||||||||||||||||
| 382 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 383 | 26 | ▶ | die "Missing condition" unless(exists($attr->{'cnd'})); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 384 | 26 | ▶ | if ($attr->{'cnd'} =~ /^(.*?)(==|!=|<=?|>=?)(.*)$/) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 385 | 22 | ▶ | $self->print("$tag: Numeric condition $1 $2 $3\n") if $debug; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 386 | 22 | ▶ | my $left = $1 || 0; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$1 || 0
MC/DC0%0/1
$1 || 0
$1
Truth table50%1/2
A
A= $1
| |||||||||||||||||||||||||||||||||||||||||||||||
| 387 | 22 | my $cnd = $2; | |||||||||||||||||||||||||||||||||||||||||||||
| 388 | 22 | ▶ | my $right = $3 || 0; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$3 || 0
MC/DC0%0/1
$3 || 0
$3
Truth table50%1/2
A
A= $3
| |||||||||||||||||||||||||||||||||||||||||||||||
| 389 | 22 | ▶ | return ($left == $right) if $cnd eq '=='; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 390 | 19 | ▶ | return ($left != $right) if $cnd eq '!='; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 391 | 16 | ▶ | return ($left < $right) if $cnd eq '<'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 392 | 9 | ▶ | return ($left > $right) if $cnd eq '>'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 393 | 6 | ▶ | return ($left >= $right) if $cnd eq '>='; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 394 | 3 | return ($left <= $right); | |||||||||||||||||||||||||||||||||||||||||||||
| 395 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 396 | die "Cannot parse condition cnd=$attr->{'cnd'}" | ||||||||||||||||||||||||||||||||||||||||||||||
| 397 | 4 | ▶ | unless $attr->{'cnd'} =~ /^\s*\'(.*?)\'\s*(eq|ne)\s*\'(.*)\'\s*$/; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 398 | 4 | ▶ | $self->print("$tag: String condition $1 $2 $3\n") if $debug; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 399 | 4 | ▶ | return $1 eq $3 if $2 eq 'eq'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 400 | 2 | return $1 ne $3; | |||||||||||||||||||||||||||||||||||||||||||||
| 401 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 402 | |||||||||||||||||||||||||||||||||||||||||||||||
| 403 | |||||||||||||||||||||||||||||||||||||||||||||||
| 404 | |||||||||||||||||||||||||||||||||||||||||||||||
| 405 | 16 | ▶ | sub init { 1 } | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
init: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 406 | |||||||||||||||||||||||||||||||||||||||||||||||
| 407 | 0 | ▶ | sub Stop ($) { my($self) = @_; $self->{_ep_stop} = 1; } | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Stop: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 408 | |||||||||||||||||||||||||||||||||||||||||||||||
| 409 | |||||||||||||||||||||||||||||||||||||||||||||||
| 410 | 2 | ▶ | sub _ep_comment { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_ep_comment: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 411 | 2 | my $self = shift; my $attr = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 412 | 2 | $self->AttrVal($attr->{'comment'}, @_); | |||||||||||||||||||||||||||||||||||||||||||||
| 413 | 2 | ''; | |||||||||||||||||||||||||||||||||||||||||||||
| 414 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 415 | |||||||||||||||||||||||||||||||||||||||||||||||
| 416 | |||||||||||||||||||||||||||||||||||||||||||||||
| 417 | 15 | ▶ | sub _ep_package { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_ep_package: called CC=9 SCAR=22.3
| |||||||||||||||||||||||||||||||||||||||||||||||
| 418 | 15 | my $self = shift; my $attr = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 419 | 15 | my $package = $attr->{name}; | |||||||||||||||||||||||||||||||||||||||||||||
| 420 | 15 | ▶ | if (!exists($attr->{'require'}) || $attr->{'require'}) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
not exists $attr->{"require"} or $attr->{"require"}
MC/DC0%0/2
not exists $attr->{"require"} or $attr->{"require"}
not exists $attr->{"require"}
$attr->{"require"}
Truth table33%1/3
not(A) or B
A= not exists $attr->{"require"}B= $attr->{"require"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 421 | my @inc = ($ENV{'DOCUMENT_ROOT'} . $attr->{'lib'}, | ||||||||||||||||||||||||||||||||||||||||||||||
| 422 | 15 | ▶ | $attr->{'lib'}, @INC) if $attr->{'lib'}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 423 | 15 | ▶ | local @INC = @inc if @inc; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 424 | 15 | my $ppm = $package; | |||||||||||||||||||||||||||||||||||||||||||||
| 425 | 15 | $ppm =~ s/\:\:/\//g; | |||||||||||||||||||||||||||||||||||||||||||||
| 426 | 15 | require "$ppm.pm"; | |||||||||||||||||||||||||||||||||||||||||||||
| 427 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 428 | |||||||||||||||||||||||||||||||||||||||||||||||
| 429 | 15 | ▶ | my $pack = ($self->{'_ep_package'} || 0) + 1; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$self->{'_ep_package'} || 0
MC/DC100%1/1
$self->{'_ep_package'} || 0
$self->{'_ep_package'}
Truth table100%2/2
A
A= $self->{'_ep_package'}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 430 | 15 | ▶ | if ($attr->{'isa'} || $self->{'_ep_package'}) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$attr->{"isa"} or $self->{"_ep_package"}
MC/DC50%1/2
$attr->{"isa"} or $self->{"_ep_package"}
$attr->{"isa"}
$self->{"_ep_package"}
Truth table66%2/3
A or B
A= $attr->{"isa"}B= $self->{"_ep_package"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 431 | # If ep-package is called multiple times, or if $attr->{'isa'} | ||||||||||||||||||||||||||||||||||||||||||||||
| 432 | # is set, we create a new package and bless $self into it. | ||||||||||||||||||||||||||||||||||||||||||||||
| 433 | 1 | my @isa; | |||||||||||||||||||||||||||||||||||||||||||||
| 434 | 1 | ▶ | @isa = split(',', $attr->{'isa'}) if @isa; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 435 | 1 | my $p = ref($self); | |||||||||||||||||||||||||||||||||||||||||||||
| 436 | 10 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 437 | 1 | push(@isa, $p); | |||||||||||||||||||||||||||||||||||||||||||||
| 438 | 1 | my $bpack = "HTML::EP::PACK$pack"; | |||||||||||||||||||||||||||||||||||||||||||||
| 439 | 1 | @{"$bpack\::ISA"} = ($package, @isa); | |||||||||||||||||||||||||||||||||||||||||||||
| 440 | 1 | bless($self, $bpack); | |||||||||||||||||||||||||||||||||||||||||||||
| 441 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 442 | # Otherwise it's faster to bless $self into the package | ||||||||||||||||||||||||||||||||||||||||||||||
| 443 | 14 | bless($self, $package); | |||||||||||||||||||||||||||||||||||||||||||||
| 444 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 445 | 15 | $self->{'_ep_package'} = $pack; | |||||||||||||||||||||||||||||||||||||||||||||
| 446 | |||||||||||||||||||||||||||||||||||||||||||||||
| 447 | 15 | $self->init($attr); | |||||||||||||||||||||||||||||||||||||||||||||
| 448 | 15 | ''; | |||||||||||||||||||||||||||||||||||||||||||||
| 449 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 450 | |||||||||||||||||||||||||||||||||||||||||||||||
| 451 | 0 | ▶ | sub _ep_debug { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_ep_debug: not called CC=12 SCAR=50.5
| |||||||||||||||||||||||||||||||||||||||||||||||
| 452 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 453 | 0 | my $cgi = $self->{'cgi'}; | |||||||||||||||||||||||||||||||||||||||||||||
| 454 | |||||||||||||||||||||||||||||||||||||||||||||||
| 455 | 0 | my $debughosts = $self->{'_ep_config'}->{'debughosts'}; | |||||||||||||||||||||||||||||||||||||||||||||
| 456 | 0 | ▶ | if ($debughosts) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 457 | 0 | my $remoteip = ''; | |||||||||||||||||||||||||||||||||||||||||||||
| 458 | 0 | my $remotehost = ''; | |||||||||||||||||||||||||||||||||||||||||||||
| 459 | 0 | ▶ | if ($self->{'_ep_r'} && (my $r = $self->{'_ep_r'})) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->{"_ep_r"} and my $r = $self->{"_ep_r"}
MC/DC0%0/2
$self->{"_ep_r"} and my $r = $self->{"_ep_r"}
$self->{"_ep_r"}
my $r = $self->{"_ep_r"}
Truth table0%0/3
A and B
A= $self->{"_ep_r"}B= my $r = $self->{"_ep_r"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 460 | 0 | ▶ | $remoteip = ($r->connection()->remote_ip() || ''); | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$r->connection->remote_ip || ''
MC/DC0%0/1
$r->connection->remote_ip || ''
$r->connection->remote_ip
Truth table0%0/2
A
A= $r->connection->remote_ip
| |||||||||||||||||||||||||||||||||||||||||||||||
| 461 | 0 | ▶ | $remotehost = ($r->get_remote_host() || ''); | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$r->get_remote_host || ''
MC/DC0%0/1
$r->get_remote_host || ''
$r->get_remote_host
Truth table0%0/2
A
A= $r->get_remote_host
| |||||||||||||||||||||||||||||||||||||||||||||||
| 462 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 463 | 0 | ▶ | $remoteip = ($ENV{'REMOTE_ADDR'} || ''); | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$ENV{'REMOTE_ADDR'} || ''
MC/DC0%0/1
$ENV{'REMOTE_ADDR'} || ''
$ENV{'REMOTE_ADDR'}
Truth table0%0/2
A
A= $ENV{'REMOTE_ADDR'}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 464 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 465 | 0 | ▶ | die "Debugging not permitted from $remoteip" | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$remoteip and not $remoteip =~ /$debughosts/ and not $remotehost =~ /$debughosts/
$remoteip and not $remoteip =~ /$debughosts/
MC/DC0%0/3
$remoteip and not $remoteip =~ /$debughosts/ and not $remotehost =~ /$debughosts/
$remoteip
not $remoteip =~ /$debughosts/
not $remotehost =~ /$debughosts/
Truth table0%0/4
A and not(B) and not(C)
A= $remoteipB= not $remoteip =~ /$debughosts/C= not $remotehost =~ /$debughosts/
| |||||||||||||||||||||||||||||||||||||||||||||||
| 466 | . " ($remotehost), debug hosts = $debughosts" | ||||||||||||||||||||||||||||||||||||||||||||||
| 467 | if (($remoteip and $remoteip !~ /$debughosts/) and | ||||||||||||||||||||||||||||||||||||||||||||||
| 468 | ($remotehost !~ /$debughosts/)); | ||||||||||||||||||||||||||||||||||||||||||||||
| 469 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 470 | |||||||||||||||||||||||||||||||||||||||||||||||
| 471 | 0 | $| = 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 472 | 0 | $self->print($cgi->header('-type' => 'text/plain')); | |||||||||||||||||||||||||||||||||||||||||||||
| 473 | 0 | $self->print("Entering debugging mode;", | |||||||||||||||||||||||||||||||||||||||||||||
| 474 | " list of input values:\n"); | ||||||||||||||||||||||||||||||||||||||||||||||
| 475 | 0 | foreach my $p ($cgi->param()) { | |||||||||||||||||||||||||||||||||||||||||||||
| 476 | 0 | $self->print(" $p = ", $cgi->param($p), "\n"); | |||||||||||||||||||||||||||||||||||||||||||||
| 477 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 478 | 0 | ▶ | $self->{'debug'} = $cgi->param('debug') || 1; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$cgi->param('debug') || 1
MC/DC0%0/1
$cgi->param('debug') || 1
$cgi->param('debug')
Truth table0%0/2
A
A= $cgi->param('debug')
| |||||||||||||||||||||||||||||||||||||||||||||||
| 479 | 0 | ''; | |||||||||||||||||||||||||||||||||||||||||||||
| 480 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 481 | |||||||||||||||||||||||||||||||||||||||||||||||
| 482 | 2 | ▶ | sub GetPerlCode { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
GetPerlCode: called CC=7 SCAR=32.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 483 | 2 | my $self = shift; my $attr = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 484 | |||||||||||||||||||||||||||||||||||||||||||||||
| 485 | 2 | my $code; | |||||||||||||||||||||||||||||||||||||||||||||
| 486 | 2 | ▶ | if (my $file = $attr->{'src'}) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 487 | 0 | my $fh = Symbol::gensym(); | |||||||||||||||||||||||||||||||||||||||||||||
| 488 | 0 | ▶ | if (! -f $file && -f ($self->{env}->{DOCUMENT_ROOT} . $file)) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not -f $file and -f $self->{"env"}{"DOCUMENT_ROOT"} . $file
MC/DC0%0/2
not -f $file and -f $self->{"env"}{"DOCUMENT_ROOT"} . $file
not -f $file
-f $self->{"env"}{"DOCUMENT_ROOT"} . $file
Truth table0%0/3
not(A) and B
A= not -f $fileB= -f $self->{"env"}{"DOCUMENT_ROOT"} . $file
| |||||||||||||||||||||||||||||||||||||||||||||||
| 489 | 0 | $file = ($self->{env}->{DOCUMENT_ROOT} . $file); | |||||||||||||||||||||||||||||||||||||||||||||
| 490 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 491 | 0 | ▶ | open($fh, "<$file") || die "Cannot open $file: $!"; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 492 | 0 | local $/ = undef; | |||||||||||||||||||||||||||||||||||||||||||||
| 493 | 0 | $code = <$fh>; | |||||||||||||||||||||||||||||||||||||||||||||
| 494 | 0 | ▶ | die "Error while reading $file: $!" unless defined($fh) and close($fh); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $fh and close $fh
MC/DC0%0/2
defined $fh and close $fh
defined $fh
close $fh
Truth table0%0/3
A and B
A= defined $fhB= close $fh
| |||||||||||||||||||||||||||||||||||||||||||||||
| 495 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 496 | 2 | $code = $self->AttrVal($attr->{'code'}, @_); | |||||||||||||||||||||||||||||||||||||||||||||
| 497 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 498 | 2 | $code; | |||||||||||||||||||||||||||||||||||||||||||||
| 499 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 500 | |||||||||||||||||||||||||||||||||||||||||||||||
| 501 | 2 | ▶ | sub EvalPerlCode { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
EvalPerlCode: called CC=8 SCAR=28.7
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 502 | 2 | my($self, $attr, $code) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 503 | 2 | my $output; | |||||||||||||||||||||||||||||||||||||||||||||
| 504 | 2 | ▶ | if ($attr->{'safe'}) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 505 | 0 | my $compartment = $self->{_ep_compartment}; | |||||||||||||||||||||||||||||||||||||||||||||
| 506 | 0 | ▶ | if (!$compartment) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 507 | 0 | require Safe; | |||||||||||||||||||||||||||||||||||||||||||||
| 508 | 0 | $compartment = $self->{_ep_compartment} = Safe->new(); | |||||||||||||||||||||||||||||||||||||||||||||
| 509 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 510 | 0 | ▶ | if ($self->{debug}) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 511 | 0 | $self->print("Evaluating in Safe compartment:\n$code\n"); | |||||||||||||||||||||||||||||||||||||||||||||
| 512 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 513 | 0 | local $_ = $self; # The 'local' is required for garbage collection | |||||||||||||||||||||||||||||||||||||||||||||
| 514 | 0 | $output = $compartment->reval($code); | |||||||||||||||||||||||||||||||||||||||||||||
| 515 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 516 | $code = "package ". | ||||||||||||||||||||||||||||||||||||||||||||||
| 517 | 2 | ▶ | ($attr->{'package'} || "HTML::EP::main").";".$code; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$attr->{'package'} || 'HTML::EP::main'
MC/DC0%0/1
$attr->{'package'} || 'HTML::EP::main'
$attr->{'package'}
Truth table50%1/2
A
A= $attr->{'package'}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 518 | 2 | ▶ | $self->print("Evaluating script:\n$code\n") if $self->{'debug'}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 519 | 2 | local $_ = $self; # The 'local' is required for garbage collection | |||||||||||||||||||||||||||||||||||||||||||||
| 520 | 2 | $output = eval $code; | |||||||||||||||||||||||||||||||||||||||||||||
| 521 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 522 | 2 | ▶ | die $@ if $@; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 523 | $self->printf("Script returned:\n$output\nEnd of output.\n") | ||||||||||||||||||||||||||||||||||||||||||||||
| 524 | 2 | ▶ | if $self->{debug}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 525 | 2 | $output; | |||||||||||||||||||||||||||||||||||||||||||||
| 526 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 527 | |||||||||||||||||||||||||||||||||||||||||||||||
| 528 | 2 | ▶ | sub EncodeByAttr { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
EncodeByAttr: called CC=7 SCAR=28.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 529 | 2 | my($self, $attr, $str) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 530 | 2 | my $debug = $self->{'debug'}; | |||||||||||||||||||||||||||||||||||||||||||||
| 531 | 2 | ▶ | $self->print("EncodeByAttr: Input $str\n") if $debug; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 532 | 2 | ▶ | if (my $type = $attr->{'output'}) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 533 | 0 | ▶ | if ($type eq 'html') { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 534 | 0 | $str = $self->escapeHTML($str); | |||||||||||||||||||||||||||||||||||||||||||||
| 535 | } elsif ($type eq 'htmlbr') { | ||||||||||||||||||||||||||||||||||||||||||||||
| 536 | 0 | $str = $self->escapeHTML($str); | |||||||||||||||||||||||||||||||||||||||||||||
| 537 | 0 | $str =~ s/\n/<br>/sg; | |||||||||||||||||||||||||||||||||||||||||||||
| 538 | } elsif ($type eq 'url') { | ||||||||||||||||||||||||||||||||||||||||||||||
| 539 | 0 | $str = CGI->escape($str); | |||||||||||||||||||||||||||||||||||||||||||||
| 540 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 541 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 542 | 2 | ▶ | $self->print("EncodeByAttr: Output $str\n") if $debug; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 543 | 2 | $str; | |||||||||||||||||||||||||||||||||||||||||||||
| 544 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 545 | |||||||||||||||||||||||||||||||||||||||||||||||
| 546 | 2 | ▶ | sub _ep_perl { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_ep_perl: called CC=2 SCAR=7.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 547 | 2 | my $self = shift; my $attr = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 548 | 2 | my $code = $self->GetPerlCode($attr, @_); | |||||||||||||||||||||||||||||||||||||||||||||
| 549 | 2 | ▶ | return undef unless defined $code; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 550 | 2 | $self->EncodeByAttr($attr, $self->EvalPerlCode($attr, $code)); | |||||||||||||||||||||||||||||||||||||||||||||
| 551 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 552 | |||||||||||||||||||||||||||||||||||||||||||||||
| 553 | |||||||||||||||||||||||||||||||||||||||||||||||
| 554 | 0 | ▶ | sub _ep_database ($$;$) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_ep_database: not called CC=6 SCAR=37.4
| |||||||||||||||||||||||||||||||||||||||||||||||
| 555 | 0 | my $self = shift; my $attr = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 556 | 0 | ▶ | my $dsn = $attr->{'dsn'} || $self->{env}->{DBI_DSN}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$attr->{'dsn'} || $self->{'env'}{'DBI_DSN'}
MC/DC0%0/2
$attr->{'dsn'} || $self->{'env'}{'DBI_DSN'}
$attr->{'dsn'}
$self->{'env'}{'DBI_DSN'}
Truth table0%0/3
A || B
A= $attr->{'dsn'}B= $self->{'env'}{'DBI_DSN'}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 557 | 0 | ▶ | my $user = $attr->{'user'} || $self->{env}->{DBI_USER}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$attr->{'user'} || $self->{'env'}{'DBI_USER'}
MC/DC0%0/2
$attr->{'user'} || $self->{'env'}{'DBI_USER'}
$attr->{'user'}
$self->{'env'}{'DBI_USER'}
Truth table0%0/3
A || B
A= $attr->{'user'}B= $self->{'env'}{'DBI_USER'}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 558 | 0 | ▶ | my $pass = $attr->{'password'} || $self->{env}->{DBI_PASS}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$attr->{'password'} || $self->{'env'}{'DBI_PASS'}
MC/DC0%0/2
$attr->{'password'} || $self->{'env'}{'DBI_PASS'}
$attr->{'password'}
$self->{'env'}{'DBI_PASS'}
Truth table0%0/3
A || B
A= $attr->{'password'}B= $self->{'env'}{'DBI_PASS'}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 559 | 0 | ▶ | my $dbhvar = $attr->{'dbh'} || 'dbh'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$attr->{'dbh'} || 'dbh'
MC/DC0%0/1
$attr->{'dbh'} || 'dbh'
$attr->{'dbh'}
Truth table0%0/2
A
A= $attr->{'dbh'}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 560 | 0 | require DBI; | |||||||||||||||||||||||||||||||||||||||||||||
| 561 | $self->printf("Connecting to database: dsn = %s, user = %s," | ||||||||||||||||||||||||||||||||||||||||||||||
| 562 | 0 | ▶ | . " pass = %s\n", $dsn, $user, $pass) if $self->{'debug'}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 563 | 0 | $self->{$dbhvar} = DBI->connect($dsn, $user, $pass, | |||||||||||||||||||||||||||||||||||||||||||||
| 564 | { 'RaiseError' => 1, 'Warn' => 0, | ||||||||||||||||||||||||||||||||||||||||||||||
| 565 | 'PrintError' => 0 }); | ||||||||||||||||||||||||||||||||||||||||||||||
| 566 | 0 | ''; | |||||||||||||||||||||||||||||||||||||||||||||
| 567 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 568 | |||||||||||||||||||||||||||||||||||||||||||||||
| 569 | |||||||||||||||||||||||||||||||||||||||||||||||
| 570 | 0 | ▶ | sub SqlSetupStatement { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
SqlSetupStatement: not called CC=8 SCAR=42.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 571 | 0 | my($self, $attr, $dbh, $statement) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 572 | |||||||||||||||||||||||||||||||||||||||||||||||
| 573 | 0 | ▶ | my $start_at = $attr->{'startat'} || 0; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$attr->{'startat'} || 0
MC/DC0%0/1
$attr->{'startat'} || 0
$attr->{'startat'}
Truth table0%0/2
A
A= $attr->{'startat'}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 574 | 0 | ▶ | my $limit = $attr->{'limit'} || -1; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$attr->{'limit'} || -1
MC/DC0%0/1
$attr->{'limit'} || -1
$attr->{'limit'}
Truth table0%0/2
A
A= $attr->{'limit'}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 575 | 0 | ▶ | if (($start_at || $limit != -1) && | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$start_at || $limit != -1 and $dbh->{"ImplementorClass"} eq "DBD::mysql::db"
$start_at or $limit != -1
MC/DC0%0/3
$start_at || $limit != -1 and $dbh->{"ImplementorClass"} eq "DBD::mysql::db"
$start_at
$limit != -1
$dbh->{"ImplementorClass"} eq "DBD::mysql::db"
Truth table0%0/5
A or B and C
A= $start_atB= $limit != -1C= $dbh->{"ImplementorClass"} eq "DBD::mysql::db"
| |||||||||||||||||||||||||||||||||||||||||||||||
| 576 | $dbh->{'ImplementorClass'} eq 'DBD::mysql::db') { | ||||||||||||||||||||||||||||||||||||||||||||||
| 577 | 0 | $statement .= " LIMIT $start_at, $limit"; | |||||||||||||||||||||||||||||||||||||||||||||
| 578 | 0 | $start_at = 0; | |||||||||||||||||||||||||||||||||||||||||||||
| 579 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 580 | 0 | ▶ | if ($self->{'debug'}) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 581 | 0 | $self->print("Executing query, statement = $statement\n"); | |||||||||||||||||||||||||||||||||||||||||||||
| 582 | $self->printf("Result starting at row %s\n", | ||||||||||||||||||||||||||||||||||||||||||||||
| 583 | 0 | ▶ | $attr->{'startat'} || 0); | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$attr->{'startat'} || 0
MC/DC0%0/1
$attr->{'startat'} || 0
$attr->{'startat'}
Truth table0%0/2
A
A= $attr->{'startat'}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 584 | 0 | $self->printf("Rows limited to %s\n", $attr->{'limit'}); | |||||||||||||||||||||||||||||||||||||||||||||
| 585 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 586 | 0 | my $sth = $dbh->prepare($statement); | |||||||||||||||||||||||||||||||||||||||||||||
| 587 | 0 | $sth->execute(); | |||||||||||||||||||||||||||||||||||||||||||||
| 588 | 0 | ($sth, $start_at, $limit) | |||||||||||||||||||||||||||||||||||||||||||||
| 589 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 590 | |||||||||||||||||||||||||||||||||||||||||||||||
| 591 | 0 | ▶ | sub SqlSetupResult { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
SqlSetupResult: not called CC=12 SCAR=50.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 592 | 0 | my($self, $attr, $sth, $start_at, $limit) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 593 | 0 | my $result = $attr->{'result'}; | |||||||||||||||||||||||||||||||||||||||||||||
| 594 | 0 | my $list = []; | |||||||||||||||||||||||||||||||||||||||||||||
| 595 | 0 | my $ref; | |||||||||||||||||||||||||||||||||||||||||||||
| 596 | 0 | ▶ | while ($limit && $start_at-- > 0) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$limit and $start_at-- > 0
MC/DC0%0/2
$limit and $start_at-- > 0
$limit
$start_at-- > 0
Truth table0%0/3
A and B
A= $limitB= $start_at-- > 0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 597 | 0 | ▶ | if (!$sth->fetchrow_arrayref()) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 598 | 0 | $limit = 0; | |||||||||||||||||||||||||||||||||||||||||||||
| 599 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||||||
| 600 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 601 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 602 | my $resultmethod = | ||||||||||||||||||||||||||||||||||||||||||||||
| 603 | 0 | ▶ | (exists($attr->{'resulttype'}) && $attr->{'resulttype'} =~ /array/) ? | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
exists $attr->{"resulttype"} and $attr->{"resulttype"} =~ /array/
MC/DC0%0/2
exists $attr->{"resulttype"} and $attr->{"resulttype"} =~ /array/
exists $attr->{"resulttype"}
$attr->{"resulttype"} =~ /array/
Truth table0%0/3
A and B
A= exists $attr->{"resulttype"}B= $attr->{"resulttype"} =~ /array/
| |||||||||||||||||||||||||||||||||||||||||||||||
| 604 | "fetchrow_arrayref" : "fetchrow_hashref"; | ||||||||||||||||||||||||||||||||||||||||||||||
| 605 | 0 | ▶ | while ($limit-- && ($ref = $sth->$resultmethod())) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$limit-- and $ref = $sth->$resultmethod
MC/DC0%0/2
$limit-- and $ref = $sth->$resultmethod
$limit--
$ref = $sth->$resultmethod
Truth table0%0/3
A and B
A= $limit--B= $ref = $sth->$resultmethod
| |||||||||||||||||||||||||||||||||||||||||||||||
| 606 | 0 | ▶ | push(@$list, (ref($ref) eq 'ARRAY') ? [@$ref] : {%$ref}); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 607 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 608 | 0 | ▶ | if (exists($attr->{'resulttype'}) && | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
exists $attr->{"resulttype"} and $attr->{"resulttype"} =~ /^single_/
MC/DC0%0/2
exists $attr->{"resulttype"} and $attr->{"resulttype"} =~ /^single_/
exists $attr->{"resulttype"}
$attr->{"resulttype"} =~ /^single_/
Truth table0%0/3
A and B
A= exists $attr->{"resulttype"}B= $attr->{"resulttype"} =~ /^single_/
| |||||||||||||||||||||||||||||||||||||||||||||||
| 609 | $attr->{'resulttype'} =~ /^single_/) { | ||||||||||||||||||||||||||||||||||||||||||||||
| 610 | 0 | $self->{$result} = $list->[0]; | |||||||||||||||||||||||||||||||||||||||||||||
| 611 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 612 | 0 | $self->{$result} = $list; | |||||||||||||||||||||||||||||||||||||||||||||
| 613 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 614 | 0 | $self->{"$result\_rows"} = scalar(@$list); | |||||||||||||||||||||||||||||||||||||||||||||
| 615 | 0 | ▶ | $self->print("Result: ", scalar(@$list), " rows.\n") if $self->{'debug'}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 616 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 617 | |||||||||||||||||||||||||||||||||||||||||||||||
| 618 | 0 | ▶ | sub _ep_query { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_ep_query: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 619 | 0 | my($self, $attr, $tokens, $token) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 620 | 0 | my $debug = $self->{'debug'}; | |||||||||||||||||||||||||||||||||||||||||||||
| 621 | 0 | my $statement = $self->AttrVal($attr->{'statement'}, $tokens, $token, 1); | |||||||||||||||||||||||||||||||||||||||||||||
| 622 | 0 | ▶ | my $dbh = $self->{$attr->{'dbh'} || 'dbh'} || die "Not connected"; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/4
$$self{$attr->{'dbh'} or 'dbh'} || die('Not connected')
$attr->{'dbh'} || 'dbh'
MC/DC0%0/1
$$self{$attr->{'dbh'} or 'dbh'} || die('Not connected')
$$self{$attr->{'dbh'} or 'dbh'}
MC/DC0%0/1
$attr->{'dbh'} || 'dbh'
$attr->{'dbh'}
Truth table0%0/2
A
A= $$self{$attr->{'dbh'} or 'dbh'}
Truth table0%0/2
A
A= $attr->{'dbh'}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 623 | 0 | ▶ | if (!exists($attr->{'result'})) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 624 | 0 | ▶ | $self->print("Doing Query: $statement\n") if $debug; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 625 | 0 | $dbh->do($statement); | |||||||||||||||||||||||||||||||||||||||||||||
| 626 | 0 | return ''; | |||||||||||||||||||||||||||||||||||||||||||||
| 627 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 628 | |||||||||||||||||||||||||||||||||||||||||||||||
| 629 | 0 | $self->SqlSetupResult($attr, | |||||||||||||||||||||||||||||||||||||||||||||
| 630 | $self->SqlSetupStatement($attr, $dbh, $statement)); | ||||||||||||||||||||||||||||||||||||||||||||||
| 631 | 0 | ''; | |||||||||||||||||||||||||||||||||||||||||||||
| 632 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 633 | |||||||||||||||||||||||||||||||||||||||||||||||
| 634 | |||||||||||||||||||||||||||||||||||||||||||||||
| 635 | 1 | ▶ | sub _ep_select ($$;$) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_ep_select: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 636 | 1 | my $self = shift; my $attr = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 637 | 1 | my @tags; | |||||||||||||||||||||||||||||||||||||||||||||
| 638 | 1 | ▶ | while (my($var, $val) = each %$attr) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 639 | 4 | ▶ | if ($var !~ /^template|range|format|items?|selected(?:\-text)?$/i){ | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 640 | 1 | push(@tags, sprintf('%s="%s"', $var, $self->escapeHTML($val))); | |||||||||||||||||||||||||||||||||||||||||||||
| 641 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 642 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 643 | |||||||||||||||||||||||||||||||||||||||||||||||
| 644 | 1 | $attr->{'format'} = '<SELECT ' . join(" ", @tags) . '>$@output$</SELECT>'; | |||||||||||||||||||||||||||||||||||||||||||||
| 645 | 1 | $self->_ep_list($attr, @_); | |||||||||||||||||||||||||||||||||||||||||||||
| 646 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 647 | |||||||||||||||||||||||||||||||||||||||||||||||
| 648 | |||||||||||||||||||||||||||||||||||||||||||||||
| 649 | 20 | ▶ | sub _ep_list { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_ep_list: called CC=16 SCAR=29.1
| |||||||||||||||||||||||||||||||||||||||||||||||
| 650 | 20 | my($self, $attr, $tokens, $token) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 651 | 20 | my $debug = $self->{'debug'}; | |||||||||||||||||||||||||||||||||||||||||||||
| 652 | 20 | my $template; | |||||||||||||||||||||||||||||||||||||||||||||
| 653 | 20 | ▶ | if (defined($attr->{'template'})) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 654 | 0 | my $parser = HTML::EP::Parser->new(); | |||||||||||||||||||||||||||||||||||||||||||||
| 655 | 0 | $parser->text($attr->{'template'}); | |||||||||||||||||||||||||||||||||||||||||||||
| 656 | 0 | $template = HTML::EP::Tokens->new('tokens' => $parser->{'_ep_tokens'}); | |||||||||||||||||||||||||||||||||||||||||||||
| 657 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 658 | 20 | my $first = $tokens->First(); | |||||||||||||||||||||||||||||||||||||||||||||
| 659 | 20 | my $last = $self->FindEndTag($tokens, $token->{'tag'}); | |||||||||||||||||||||||||||||||||||||||||||||
| 660 | 20 | $template = $tokens->Clone($first, $last-1); | |||||||||||||||||||||||||||||||||||||||||||||
| 661 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 662 | 20 | my $output = ''; | |||||||||||||||||||||||||||||||||||||||||||||
| 663 | 20 | my($list, $range); | |||||||||||||||||||||||||||||||||||||||||||||
| 664 | 20 | ▶ | if ($range = $attr->{'range'}) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 665 | 16 | ▶ | $list = [ map { $_ =~ /(\d+)\.\.(\d+)/ ? ($1 .. $2) : $_} | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 666 | split(/,/, $range) ]; | ||||||||||||||||||||||||||||||||||||||||||||||
| 667 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 668 | 4 | my $items = $attr->{'items'}; | |||||||||||||||||||||||||||||||||||||||||||||
| 669 | $list = ref($items) ? $items : | ||||||||||||||||||||||||||||||||||||||||||||||
| 670 | ($items =~ /^(\w+)((?:\-\>\w+)+)$/) ? | ||||||||||||||||||||||||||||||||||||||||||||||
| 671 | 4 | ▶ | $self->FindVar($1, $2) : $self->{$items}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 672 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 673 | 20 | ▶ | $self->print("_ep_list: Template = $template, Items = ", @$list, "\n") | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 674 | if $debug; | ||||||||||||||||||||||||||||||||||||||||||||||
| 675 | 20 | ▶ | my $l = $attr->{'item'} or die "Missing item name"; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 676 | 20 | my $i = 0; | |||||||||||||||||||||||||||||||||||||||||||||
| 677 | 20 | my $selected = $attr->{'selected'}; | |||||||||||||||||||||||||||||||||||||||||||||
| 678 | 20 | my $isSelected; | |||||||||||||||||||||||||||||||||||||||||||||
| 679 | 20 | foreach my $ref (@$list) { | |||||||||||||||||||||||||||||||||||||||||||||
| 680 | 66 | $self->{$l} = $ref; | |||||||||||||||||||||||||||||||||||||||||||||
| 681 | 66 | ▶ | $self->{'i'} = $i++ unless $l eq 'i'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 682 | 66 | ▶ | if ($selected) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 683 | 5 | ▶ | if (ref($ref) eq 'HASH') { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 684 | 0 | $isSelected = $ref->{'val'} eq $selected; | |||||||||||||||||||||||||||||||||||||||||||||
| 685 | } elsif (ref($ref) eq 'ARRAY') { | ||||||||||||||||||||||||||||||||||||||||||||||
| 686 | 0 | $isSelected = $ref->[0] eq $selected; | |||||||||||||||||||||||||||||||||||||||||||||
| 687 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 688 | 5 | $isSelected = $ref eq $selected; | |||||||||||||||||||||||||||||||||||||||||||||
| 689 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 690 | $self->{'selected'} = $isSelected ? | ||||||||||||||||||||||||||||||||||||||||||||||
| 691 | 5 | ▶ | ($attr->{'selected-text'} || 'SELECTED') : ''; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$attr->{"selected-text"} or "SELECTED"
MC/DC0%0/1
$attr->{"selected-text"} or "SELECTED"
$attr->{"selected-text"}
Truth table50%1/2
A
A= $attr->{"selected-text"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 692 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 693 | 66 | $output .= $self->ParseVars($self->RepeatedTokenMarch($template)); | |||||||||||||||||||||||||||||||||||||||||||||
| 694 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 695 | 20 | ▶ | if (my $format = $attr->{'format'}) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 696 | 1 | $attr->{'output'} = $output; | |||||||||||||||||||||||||||||||||||||||||||||
| 697 | 1 | $format =~ s/\$([\@\#\~]?)(\w+)((?:\-\>\w+)*)\$/HTML::EP::ParseVar($attr, $1, $2, $3)/eg; | |||||||||||||||||||||||||||||||||||||||||||||
| 698 | 1 | $format; | |||||||||||||||||||||||||||||||||||||||||||||
| 699 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 700 | 19 | $output; | |||||||||||||||||||||||||||||||||||||||||||||
| 701 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 702 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 703 | |||||||||||||||||||||||||||||||||||||||||||||||
| 704 | |||||||||||||||||||||||||||||||||||||||||||||||
| 705 | 1 | ▶ | sub _ep_errhandler { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_ep_errhandler: called CC=4 SCAR=15.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 706 | 1 | my $self = shift; my $attr = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 707 | 1 | my $type = $attr->{type}; | |||||||||||||||||||||||||||||||||||||||||||||
| 708 | 1 | ▶ | $type = ($type && (lc $type) eq 'user') ? 'user' : 'system'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$type and lc $type eq "user"
MC/DC0%0/2
$type and lc $type eq "user"
$type
lc $type eq "user"
Truth table33%1/3
A and B
A= $typeB= lc $type eq "user"
| |||||||||||||||||||||||||||||||||||||||||||||||
| 709 | 1 | ▶ | if ($attr->{src}) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 710 | 0 | $self->{"_ep_err_file_$type"} = $attr->{src}; | |||||||||||||||||||||||||||||||||||||||||||||
| 711 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 712 | 1 | my $template = $self->AttrVal($attr->{'template'}, @_); | |||||||||||||||||||||||||||||||||||||||||||||
| 713 | 1 | $self->{"_ep_err_msg_$type"} = $template; | |||||||||||||||||||||||||||||||||||||||||||||
| 714 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 715 | 1 | ''; | |||||||||||||||||||||||||||||||||||||||||||||
| 716 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 717 | |||||||||||||||||||||||||||||||||||||||||||||||
| 718 | |||||||||||||||||||||||||||||||||||||||||||||||
| 719 | 2 | ▶ | sub _ep_error { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_ep_error: called CC=3 SCAR=12.3
| |||||||||||||||||||||||||||||||||||||||||||||||
| 720 | 2 | my($self, $attr, $tokens, $token) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 721 | 2 | my $msg = $self->AttrVal($attr->{'msg'}, $tokens, $token, 1); | |||||||||||||||||||||||||||||||||||||||||||||
| 722 | 2 | my $type = $attr->{'type'}; | |||||||||||||||||||||||||||||||||||||||||||||
| 723 | 2 | ▶ | $self->{_ep_err_type} = ($type && (lc $type) eq 'user') ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$type and lc $type eq "user"
MC/DC0%0/2
$type and lc $type eq "user"
$type
lc $type eq "user"
Truth table33%1/3
A and B
A= $typeB= lc $type eq "user"
| |||||||||||||||||||||||||||||||||||||||||||||||
| 724 | 2 | die $msg; | |||||||||||||||||||||||||||||||||||||||||||||
| 725 | 0 | ''; | |||||||||||||||||||||||||||||||||||||||||||||
| 726 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 727 | |||||||||||||||||||||||||||||||||||||||||||||||
| 728 | |||||||||||||||||||||||||||||||||||||||||||||||
| 729 | 0 | ▶ | sub _ep_input_sql_query { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_ep_input_sql_query: not called CC=10 SCAR=47.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 730 | 0 | my $self = shift; my $attr = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 731 | 0 | ▶ | my $dbh = $self->{'dbh'} || | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->{'dbh'} || die('Missing database-handle (Did you run ep-database?)')
MC/DC0%0/1
$self->{'dbh'} || die('Missing database-handle (Did you run ep-database?)')
$self->{'dbh'}
Truth table0%0/2
A
A= $self->{'dbh'}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 732 | die "Missing database-handle (Did you run ep-database?)"; | ||||||||||||||||||||||||||||||||||||||||||||||
| 733 | 0 | ▶ | my $dest = $attr->{'dest'} || | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$attr->{'dest'} || die(q[Missing attribute 'dest' (Destination variable)])
MC/DC0%0/1
$attr->{'dest'} || die(q[Missing attribute 'dest' (Destination variable)])
$attr->{'dest'}
Truth table0%0/2
A
A= $attr->{'dest'}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 734 | die "Missing attribute 'dest' (Destination variable)"; | ||||||||||||||||||||||||||||||||||||||||||||||
| 735 | 0 | my $debug = $self->{'debug'}; | |||||||||||||||||||||||||||||||||||||||||||||
| 736 | |||||||||||||||||||||||||||||||||||||||||||||||
| 737 | 0 | my $names = ''; | |||||||||||||||||||||||||||||||||||||||||||||
| 738 | 0 | my $values = ''; | |||||||||||||||||||||||||||||||||||||||||||||
| 739 | 0 | my $update = ''; | |||||||||||||||||||||||||||||||||||||||||||||
| 740 | 0 | my $comma = ''; | |||||||||||||||||||||||||||||||||||||||||||||
| 741 | 0 | ▶ | while (my($var, $val) = each %{$self->{$dest}}) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 742 | 0 | $names .= $comma . $var; | |||||||||||||||||||||||||||||||||||||||||||||
| 743 | 0 | my $v = $val->{'val'}; | |||||||||||||||||||||||||||||||||||||||||||||
| 744 | 0 | ▶ | $v = $dbh->quote($v) if !defined($v) || $val->{'type'} ne 'n'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not defined $v or $val->{"type"} ne "n"
MC/DC0%0/2
not defined $v or $val->{"type"} ne "n"
not defined $v
$val->{"type"} ne "n"
Truth table0%0/3
not(A) or B
A= not defined $vB= $val->{"type"} ne "n"
| |||||||||||||||||||||||||||||||||||||||||||||||
| 745 | 0 | $values .= $comma . $v; | |||||||||||||||||||||||||||||||||||||||||||||
| 746 | 0 | $update .= $comma . "$var=$v"; | |||||||||||||||||||||||||||||||||||||||||||||
| 747 | 0 | ▶ | $comma = ',' unless $comma; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 748 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 749 | 0 | my $hash = $self->{$dest}; | |||||||||||||||||||||||||||||||||||||||||||||
| 750 | 0 | $hash->{'names'} = $names; | |||||||||||||||||||||||||||||||||||||||||||||
| 751 | 0 | ▶ | print "_ep_input_sql_query: Setting $dest\->names to $names\n" if $debug; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 752 | 0 | $hash->{'values'} = $values; | |||||||||||||||||||||||||||||||||||||||||||||
| 753 | 0 | ▶ | print "_ep_input_sql_query: Setting $dest\->values to $values\n" if $debug; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 754 | 0 | $hash->{'update'} = $update; | |||||||||||||||||||||||||||||||||||||||||||||
| 755 | 0 | ▶ | print "_ep_input_sql_query: Setting $dest\->update to $update\n" if $debug; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 756 | 0 | ''; | |||||||||||||||||||||||||||||||||||||||||||||
| 757 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 758 | |||||||||||||||||||||||||||||||||||||||||||||||
| 759 | 2 | ▶ | sub _ep_input { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_ep_input: called CC=19 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 760 | 2 | my($self, $attr) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 761 | 2 | my $prefix = $attr->{'prefix'}; | |||||||||||||||||||||||||||||||||||||||||||||
| 762 | 2 | my($var, $val); | |||||||||||||||||||||||||||||||||||||||||||||
| 763 | 2 | my $cgi = $self->{'cgi'}; | |||||||||||||||||||||||||||||||||||||||||||||
| 764 | 2 | my @params = $cgi->param(); | |||||||||||||||||||||||||||||||||||||||||||||
| 765 | 2 | my $i = 0; | |||||||||||||||||||||||||||||||||||||||||||||
| 766 | 2 | my $list = $attr->{'list'}; | |||||||||||||||||||||||||||||||||||||||||||||
| 767 | 2 | my $dest = $attr->{'dest'}; | |||||||||||||||||||||||||||||||||||||||||||||
| 768 | |||||||||||||||||||||||||||||||||||||||||||||||
| 769 | 2 | ▶ | $self->{$dest} = [] if $list; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 770 | 2 | while(1) { | |||||||||||||||||||||||||||||||||||||||||||||
| 771 | 4 | my $p = $prefix; | |||||||||||||||||||||||||||||||||||||||||||||
| 772 | 4 | my $hash = {}; | |||||||||||||||||||||||||||||||||||||||||||||
| 773 | 4 | ▶ | if ($list) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 774 | 3 | $p .= "$i\_"; | |||||||||||||||||||||||||||||||||||||||||||||
| 775 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 776 | 4 | foreach $var (@params) { | |||||||||||||||||||||||||||||||||||||||||||||
| 777 | 25 | ▶ | if ($var =~ /^\Q$p\E\_?(\w+?)_(.*)$/) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 778 | 17 | my $col = $2; | |||||||||||||||||||||||||||||||||||||||||||||
| 779 | 17 | my $type = $1; | |||||||||||||||||||||||||||||||||||||||||||||
| 780 | 17 | ▶ | if ($type =~ /^d[dmy]$/) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 781 | # A date | ||||||||||||||||||||||||||||||||||||||||||||||
| 782 | 9 | ▶ | if ($hash->{$col}) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 783 | # Do this only once | ||||||||||||||||||||||||||||||||||||||||||||||
| 784 | 6 | next; | |||||||||||||||||||||||||||||||||||||||||||||
| 785 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 786 | 3 | ▶ | if (!$hash->{$col}) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 787 | 3 | my $year = $cgi->param("${p}dy_$col"); | |||||||||||||||||||||||||||||||||||||||||||||
| 788 | 3 | my $month = $cgi->param("${p}dm_$col"); | |||||||||||||||||||||||||||||||||||||||||||||
| 789 | 3 | my $day = $cgi->param("${p}dd_$col"); | |||||||||||||||||||||||||||||||||||||||||||||
| 790 | 3 | ▶ | if ($year eq '' && $month eq '' && $day eq '') { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
$year eq "" and $month eq "" and $day eq ""
$year eq "" and $month eq ""
MC/DC0%0/3
$year eq "" and $month eq "" and $day eq ""
$year eq ""
$month eq ""
$day eq ""
Truth table25%1/4
A and B and C
A= $year eq ""B= $month eq ""C= $day eq ""
| |||||||||||||||||||||||||||||||||||||||||||||||
| 791 | 0 | $val = undef; | |||||||||||||||||||||||||||||||||||||||||||||
| 792 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 793 | 3 | ▶ | if ($year < 20) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 794 | 1 | $year += 2000; | |||||||||||||||||||||||||||||||||||||||||||||
| 795 | } elsif ($year < 100) { | ||||||||||||||||||||||||||||||||||||||||||||||
| 796 | 1 | $year += 1900; | |||||||||||||||||||||||||||||||||||||||||||||
| 797 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 798 | 3 | $val = sprintf("%04d-%02d-%02d", | |||||||||||||||||||||||||||||||||||||||||||||
| 799 | $year, $month, $day); | ||||||||||||||||||||||||||||||||||||||||||||||
| 800 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 801 | 3 | $hash->{$col} = { col => $col, | |||||||||||||||||||||||||||||||||||||||||||||
| 802 | val => $val, | ||||||||||||||||||||||||||||||||||||||||||||||
| 803 | type => 'd', | ||||||||||||||||||||||||||||||||||||||||||||||
| 804 | year => $year, | ||||||||||||||||||||||||||||||||||||||||||||||
| 805 | month => $month, | ||||||||||||||||||||||||||||||||||||||||||||||
| 806 | day => $day | ||||||||||||||||||||||||||||||||||||||||||||||
| 807 | }; | ||||||||||||||||||||||||||||||||||||||||||||||
| 808 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 809 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 810 | 8 | ▶ | $val = ($type eq 's') ? | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 811 | join(",", $cgi->param($var)) : $cgi->param($var); | ||||||||||||||||||||||||||||||||||||||||||||||
| 812 | 8 | $hash->{$col} = { col => $col, | |||||||||||||||||||||||||||||||||||||||||||||
| 813 | type => $type, | ||||||||||||||||||||||||||||||||||||||||||||||
| 814 | val => $val | ||||||||||||||||||||||||||||||||||||||||||||||
| 815 | }; | ||||||||||||||||||||||||||||||||||||||||||||||
| 816 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 817 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 818 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 819 | 4 | ▶ | if ($list) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 820 | die "Cannot create 'names', 'values' and 'update' attributes" | ||||||||||||||||||||||||||||||||||||||||||||||
| 821 | 3 | ▶ | . " if 'list' is set." if $attr->{'sqlquery'}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 822 | 3 | ▶ | last unless %$hash; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 823 | 2 | $hash->{'i'} = $i++; | |||||||||||||||||||||||||||||||||||||||||||||
| 824 | 2 | push(@{$self->{$dest}}, $hash); | |||||||||||||||||||||||||||||||||||||||||||||
| 825 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 826 | 1 | $self->{$dest} = $hash; | |||||||||||||||||||||||||||||||||||||||||||||
| 827 | 1 | ▶ | $self->_ep_input_sql_query($attr) if $attr->{'sqlquery'}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 828 | 1 | last; | |||||||||||||||||||||||||||||||||||||||||||||
| 829 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 830 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 831 | 2 | ▶ | if ($self->{'debug'}) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 832 | $self->print("_ep_input: Gelesene Daten\n", | ||||||||||||||||||||||||||||||||||||||||||||||
| 833 | 0 | $self->Dump($self->{$dest})); | |||||||||||||||||||||||||||||||||||||||||||||
| 834 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 835 | 2 | ''; | |||||||||||||||||||||||||||||||||||||||||||||
| 836 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 837 | |||||||||||||||||||||||||||||||||||||||||||||||
| 838 | 59 | ▶ | sub _ep_if { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_ep_if: called CC=16 SCAR=27.7
| |||||||||||||||||||||||||||||||||||||||||||||||
| 839 | 59 | my($self, $attr, $tokens, $token) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 840 | 59 | my $level = 0; | |||||||||||||||||||||||||||||||||||||||||||||
| 841 | 59 | my $tag = $token->{'tag'}; | |||||||||||||||||||||||||||||||||||||||||||||
| 842 | 59 | my $state = $self->EvalIf($tag, $attr); | |||||||||||||||||||||||||||||||||||||||||||||
| 843 | 59 | ▶ | my $start = $tokens->First() if $state; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 844 | 59 | my $state_done = $state; | |||||||||||||||||||||||||||||||||||||||||||||
| 845 | 59 | my $last; | |||||||||||||||||||||||||||||||||||||||||||||
| 846 | 59 | ▶ | while (defined(my $token = $tokens->Token())) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 847 | 371 | ▶ | if ($token->{'type'} eq 'S') { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 848 | 130 | ▶ | if ($token->{'tag'} eq 'ep-if') { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 849 | 10 | ++$level; | |||||||||||||||||||||||||||||||||||||||||||||
| 850 | } elsif ($token->{'tag'} =~ /^ep-els(?:e|e?if)?$/) { | ||||||||||||||||||||||||||||||||||||||||||||||
| 851 | 114 | ▶ | next if $level; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 852 | 96 | ▶ | if ($state) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 853 | 31 | $last = $tokens->First()-1; | |||||||||||||||||||||||||||||||||||||||||||||
| 854 | 31 | $state = 0; | |||||||||||||||||||||||||||||||||||||||||||||
| 855 | } elsif (!$state_done) { | ||||||||||||||||||||||||||||||||||||||||||||||
| 856 | 42 | ▶ | if ($state = $token->{'tag'} eq 'ep-else' || | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$token->{'tag'} eq 'ep-else' || $self->EvalIf($tag, $self->ParseAttr($token->{'attr'}))
MC/DC100%2/2
$token->{'tag'} eq 'ep-else' || $self->EvalIf($tag, $self->ParseAttr($token->{'attr'}))
$token->{'tag'} eq 'ep-else'
$self->EvalIf($tag, $self->ParseAttr($token->{'attr'}))
Truth table100%3/3
A || B
A= $token->{'tag'} eq 'ep-else'B= $self->EvalIf($tag, $self->ParseAttr($token->{'attr'}))
| |||||||||||||||||||||||||||||||||||||||||||||||
| 857 | $self->EvalIf | ||||||||||||||||||||||||||||||||||||||||||||||
| 858 | ($tag, $self->ParseAttr($token->{'attr'}))) { | ||||||||||||||||||||||||||||||||||||||||||||||
| 859 | 29 | $state_done = 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 860 | 29 | $start = $tokens->First(); | |||||||||||||||||||||||||||||||||||||||||||||
| 861 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 862 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 863 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 864 | } elsif ($token->{'type'} eq 'E') { | ||||||||||||||||||||||||||||||||||||||||||||||
| 865 | 71 | ▶ | if ($token->{'tag'} eq 'ep-if') { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 866 | 69 | ▶ | next if $level--; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 867 | 59 | ▶ | return '' unless $state_done; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 868 | 55 | ▶ | $last = $tokens->First()-1 if $state; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 869 | 55 | return $self->TokenMarch($tokens->Clone($start, $last)); | |||||||||||||||||||||||||||||||||||||||||||||
| 870 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 871 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 872 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 873 | 0 | die "ep-if without /ep-if"; | |||||||||||||||||||||||||||||||||||||||||||||
| 874 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 875 | |||||||||||||||||||||||||||||||||||||||||||||||
| 876 | 0 | ▶ | sub _ep_elseif { die "ep-elseif without ep-if" } | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_ep_elseif: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 877 | 0 | ▶ | sub _ep_elsif { die "ep-elsif without ep-if" } | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_ep_elsif: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 878 | 0 | ▶ | sub _ep_else { die "ep-else without ep-if" } | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_ep_else: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 879 | |||||||||||||||||||||||||||||||||||||||||||||||
| 880 | |||||||||||||||||||||||||||||||||||||||||||||||
| 881 | 0 | ▶ | sub _ep_mail { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_ep_mail: not called CC=10 SCAR=47.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 882 | 0 | my($self, $attr, $tokens, $token) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 883 | |||||||||||||||||||||||||||||||||||||||||||||||
| 884 | my $host = (delete $attr->{'mailserver'}) || | ||||||||||||||||||||||||||||||||||||||||||||||
| 885 | 0 | ▶ | $self->{'_ep_config'}->{'mailhost'} || '127.0.0.1'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/5
delete $attr->{'mailserver'} || $self->{'_ep_config'}{'mailhost'} || '127.0.0.1'
delete $attr->{"mailserver"} or $self->{"_ep_config"}{"mailhost"}
MC/DC0%0/2
delete $attr->{'mailserver'} || $self->{'_ep_config'}{'mailhost'} || '127.0.0.1'
delete $attr->{"mailserver"}
$self->{"_ep_config"}{"mailhost"}
Truth table0%0/3
A or B
A= delete $attr->{"mailserver"}B= $self->{"_ep_config"}{"mailhost"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 886 | 0 | my @options; | |||||||||||||||||||||||||||||||||||||||||||||
| 887 | 0 | my $body = $self->AttrVal($attr->{'body'}, $tokens, $token, 1); | |||||||||||||||||||||||||||||||||||||||||||||
| 888 | 0 | require Mail::Header; | |||||||||||||||||||||||||||||||||||||||||||||
| 889 | 0 | my $msg = Mail::Header->new(); | |||||||||||||||||||||||||||||||||||||||||||||
| 890 | 0 | my($header, $val); | |||||||||||||||||||||||||||||||||||||||||||||
| 891 | 0 | ▶ | my $from = $attr->{'from'} || die "Missing header attribute: from"; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$attr->{'from'} || die('Missing header attribute: from')
MC/DC0%0/1
$attr->{'from'} || die('Missing header attribute: from')
$attr->{'from'}
Truth table0%0/2
A
A= $attr->{'from'}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 892 | 0 | ▶ | die "Missing header attribute: to" unless $attr->{'to'}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 893 | 0 | ▶ | die "Missing header attribute: subject" unless $attr->{'subject'}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 894 | 0 | ▶ | while (($header, $val) = each %$attr) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 895 | 0 | $msg->add($header, $val); | |||||||||||||||||||||||||||||||||||||||||||||
| 896 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 897 | 0 | require Net::SMTP; | |||||||||||||||||||||||||||||||||||||||||||||
| 898 | 0 | require Mail::Internet; | |||||||||||||||||||||||||||||||||||||||||||||
| 899 | 0 | my $debug = $self->{'debug'}; | |||||||||||||||||||||||||||||||||||||||||||||
| 900 | 0 | ▶ | local *STDERR if $debug; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 901 | 0 | ▶ | if ($debug) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 902 | 0 | $self->print("Headers: \n"); | |||||||||||||||||||||||||||||||||||||||||||||
| 903 | 0 | $self->print($msg->as_string()); | |||||||||||||||||||||||||||||||||||||||||||||
| 904 | 0 | $self->print("Making SMTP connection to $host.\n"); | |||||||||||||||||||||||||||||||||||||||||||||
| 905 | 0 | open(STDERR, ">&STDOUT"); | |||||||||||||||||||||||||||||||||||||||||||||
| 906 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 907 | 0 | ▶ | my $smtp = Net::SMTP->new($host, 'Debug' => $debug) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 908 | or die "Cannot open SMTP connection to $host: $!"; | ||||||||||||||||||||||||||||||||||||||||||||||
| 909 | 0 | my $mail = Mail::Internet->new([$body], Header => $msg); | |||||||||||||||||||||||||||||||||||||||||||||
| 910 | 0 | $Mail::Util::mailaddress = $from; # Ugly hack to prevent | |||||||||||||||||||||||||||||||||||||||||||||
| 911 | # DNS lookup for 'mailhost' | ||||||||||||||||||||||||||||||||||||||||||||||
| 912 | # in Mail::Util::mailaddress(). | ||||||||||||||||||||||||||||||||||||||||||||||
| 913 | 0 | $mail->smtpsend('Host' => $smtp, @options); | |||||||||||||||||||||||||||||||||||||||||||||
| 914 | 0 | $smtp->quit(); | |||||||||||||||||||||||||||||||||||||||||||||
| 915 | 0 | ''; | |||||||||||||||||||||||||||||||||||||||||||||
| 916 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 917 | |||||||||||||||||||||||||||||||||||||||||||||||
| 918 | |||||||||||||||||||||||||||||||||||||||||||||||
| 919 | 3 | ▶ | sub _ep_include { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_ep_include: called CC=5 SCAR=16.5
| |||||||||||||||||||||||||||||||||||||||||||||||
| 920 | 3 | my($self, $attr, $tokens, $token) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 921 | 3 | my $parser = HTML::EP::Parser->new(); | |||||||||||||||||||||||||||||||||||||||||||||
| 922 | 3 | ▶ | my $f = $attr->{'file'} || die "Missing file name\n"; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$attr->{'file'} || die("Missing file name\n")
MC/DC0%0/1
$attr->{'file'} || die("Missing file name\n")
$attr->{'file'}
Truth table50%1/2
A
A= $attr->{'file'}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 923 | 3 | my $df = $self->{'env'}->{'DOCUMENT_ROOT'} . $f; | |||||||||||||||||||||||||||||||||||||||||||||
| 924 | 3 | ▶ | $f = $df if -f $df; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 925 | 3 | my $fh = Symbol::gensym(); | |||||||||||||||||||||||||||||||||||||||||||||
| 926 | 3 | ▶ | open($fh, "<$f") || die "Failed to open file $f: $!"; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 927 | 3 | $parser->parse_file($fh); | |||||||||||||||||||||||||||||||||||||||||||||
| 928 | 3 | $parser->eof(); | |||||||||||||||||||||||||||||||||||||||||||||
| 929 | 3 | my $new_toks = HTML::EP::Tokens->new('tokens' => $parser->{'_ep_tokens'}); | |||||||||||||||||||||||||||||||||||||||||||||
| 930 | 3 | ▶ | $tokens->Replace | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 931 | ($tokens->First()-1, | ||||||||||||||||||||||||||||||||||||||||||||||
| 932 | { 'type' => 'I', | ||||||||||||||||||||||||||||||||||||||||||||||
| 933 | 'tokens' => $new_toks | ||||||||||||||||||||||||||||||||||||||||||||||
| 934 | }) if $tokens; # Upwards compatibility: Before EP 0.20 users | ||||||||||||||||||||||||||||||||||||||||||||||
| 935 | # didn't pass a tokens argument. | ||||||||||||||||||||||||||||||||||||||||||||||
| 936 | 3 | $self->RepeatedTokenMarch($new_toks) | |||||||||||||||||||||||||||||||||||||||||||||
| 937 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 938 | |||||||||||||||||||||||||||||||||||||||||||||||
| 939 | |||||||||||||||||||||||||||||||||||||||||||||||
| 940 | 3 | ▶ | sub _ep_exit { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_ep_exit: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 941 | 3 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 942 | # If we are inside of an ep-if, we need to collect previous output | ||||||||||||||||||||||||||||||||||||||||||||||
| 943 | 3 | $self->{'_ep_output'} = join('', @{$self->{'_ep_output_stack'}}, | |||||||||||||||||||||||||||||||||||||||||||||
| 944 | 3 | $self->{'_ep_output'}); | |||||||||||||||||||||||||||||||||||||||||||||
| 945 | 3 | die "_ep_exit, ignore"; | |||||||||||||||||||||||||||||||||||||||||||||
| 946 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 947 | |||||||||||||||||||||||||||||||||||||||||||||||
| 948 | 0 | ▶ | sub _ep_redirect { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_ep_redirect: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 949 | 0 | my $self = shift; my $attr = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 950 | 0 | ▶ | my $to = $attr->{'to'} or die "Missing redirect target"; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 951 | 0 | ▶ | $self->print("Redirecting to $to\n") if $self->{'debug'}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 952 | $self->print($self->{'cgi'}->redirect('-uri' => $to, | ||||||||||||||||||||||||||||||||||||||||||||||
| 953 | '-type' => 'text/plain', | ||||||||||||||||||||||||||||||||||||||||||||||
| 954 | '-refresh' => "0; URL=$to", | ||||||||||||||||||||||||||||||||||||||||||||||
| 955 | 0 | ▶ | $attr->{'cookies'} ? | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 956 | $self->SetCookies() : ())); | ||||||||||||||||||||||||||||||||||||||||||||||
| 957 | 0 | $self->print('<BODY BGCOLOR="#FFFFFF">Click <A HREF="', $to, | |||||||||||||||||||||||||||||||||||||||||||||
| 958 | '">here</A> to go on</BODY>'); | ||||||||||||||||||||||||||||||||||||||||||||||
| 959 | 0 | $self->Stop(); | |||||||||||||||||||||||||||||||||||||||||||||
| 960 | 0 | ''; | |||||||||||||||||||||||||||||||||||||||||||||
| 961 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 962 | |||||||||||||||||||||||||||||||||||||||||||||||
| 963 | 8 | ▶ | sub _ep_set { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_ep_set: called CC=5 SCAR=16.2
| |||||||||||||||||||||||||||||||||||||||||||||||
| 964 | 8 | my($self, $attr, $tokens, $token) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 965 | my $val = $self->AttrVal($attr->{'val'}, $tokens, $token, | ||||||||||||||||||||||||||||||||||||||||||||||
| 966 | 8 | !$attr->{'noparse'}); | |||||||||||||||||||||||||||||||||||||||||||||
| 967 | 8 | my $var = $attr->{'var'}; | |||||||||||||||||||||||||||||||||||||||||||||
| 968 | 8 | my $ref = $self; | |||||||||||||||||||||||||||||||||||||||||||||
| 969 | 8 | ▶ | while ($var =~ /(.*?)\-\>(.*)/) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 970 | 2 | my $key = $1; | |||||||||||||||||||||||||||||||||||||||||||||
| 971 | 2 | $var = $2; | |||||||||||||||||||||||||||||||||||||||||||||
| 972 | 2 | ▶ | if ($key =~ /^\d+$/) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 973 | 0 | $ref = $ref->[$key]; | |||||||||||||||||||||||||||||||||||||||||||||
| 974 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 975 | 2 | $ref = $ref->{$key}; | |||||||||||||||||||||||||||||||||||||||||||||
| 976 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 977 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 978 | 8 | ▶ | print "Setting $ref -> $var to $val\n" if $self->{'debug'}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 979 | 8 | ▶ | if ($var =~ /^\d+$/) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 980 | 1 | $ref->[$var] = $val; | |||||||||||||||||||||||||||||||||||||||||||||
| 981 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 982 | 7 | $ref->{$var} = $val; | |||||||||||||||||||||||||||||||||||||||||||||
| 983 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 984 | 8 | ''; | |||||||||||||||||||||||||||||||||||||||||||||
| 985 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 986 | |||||||||||||||||||||||||||||||||||||||||||||||
| 987 | 2 | ▶ | sub _format_NBSP { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_format_NBSP: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 988 | 2 | my $self = shift; my $str = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 989 | 2 | ▶ | if (!defined($str) || $str eq '') { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
not defined $str or $str eq ""
MC/DC50%1/2
not defined $str or $str eq ""
not defined $str
$str eq ""
Truth table66%2/3
not(A) or B
A= not defined $strB= $str eq ""
| |||||||||||||||||||||||||||||||||||||||||||||||
| 990 | 1 | $str = ' '; | |||||||||||||||||||||||||||||||||||||||||||||
| 991 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 992 | 2 | $str; | |||||||||||||||||||||||||||||||||||||||||||||
| 993 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 994 | |||||||||||||||||||||||||||||||||||||||||||||||
| 995 | |||||||||||||||||||||||||||||||||||||||||||||||
| 996 | 10 | 1; | |||||||||||||||||||||||||||||||||||||||||||||