| 1 | package YATT::Lite::WebMVC0::SiteApp; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 68 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 68 | ▶ | use warnings qw(FATAL all NONFATAL misc); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 68 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 68 | ▶ | use YATT::Lite::Breakpoint; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | sub MY () {__PACKAGE__} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 68 | ▶ | use mro 'c3'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 68 | ▶ | use 5.010; no if $] >= 5.017011, warnings => "experimental"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 68 | ▶ | use constant DEBUG_ERROR => $ENV{DEBUG_YATT_ERROR}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | #======================================== | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | # Dispatcher Layer: load and run corresponding DirApp for incoming request. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | #======================================== | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 68 | ▶ | use parent qw(YATT::Lite::Factory); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 68 | ▶ | use YATT::Lite::MFields qw/noheader | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | is_psgi | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | no_nested_query | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | mkquery_with_body_params | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | _allow_debug_from | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | _trusted_proxies | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | debug_cgi | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | debug_psgi | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | debug_connection | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | debug_backend | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | psgi_static | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | psgi_fallback | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | per_role_docroot | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | per_role_docroot_key | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | default_role | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | backend | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | site_config | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | _site_config_cache_entry | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | site_config_as_entity | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | logfile | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | overwrite_status_code_for_errors_as | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | _re_handled_ext | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | _handled_ext_list | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | ^progname | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | no_trim_script_name | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | ext_public_action | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | ^config_dir | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | _dirapp_config | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | use_sibling_config_dir | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 68 | /; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 68 | ▶ | use YATT::Lite::Util qw(cached_in split_path catch | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | lookup_path nonempty try_invoke | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | trim_ext | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | mk_http_status | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | default ckrequire | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | escape | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | trim_common_suffix_from | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | is_done | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | lexpand rootname extname untaint_any terse_dump | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | add_entity_into | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 68 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 68 | ▶ | use YATT::Lite::Util::CmdLine qw(parse_params); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 68 | ▶ | use YATT::Lite qw/Entity *SYS *CON/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 68 | our @EXPORT_OK = qw/*CON/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 68 | ▶ | use YATT::Lite::WebMVC0::DirApp (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | sub DirApp () {'YATT::Lite::WebMVC0::DirApp'} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | sub default_default_app () {'YATT::Lite::WebMVC0::DirApp'} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 192 | ▶ | sub default_ext_public_action {'ydo'} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
default_ext_public_action: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 68 | ▶ | use File::Basename; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 192 | ▶ | sub after_new { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
after_new: called CC=8 SCAR=23.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 192 | (my MY $self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 192 | $self->SUPER::after_new(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 192 | ▶ | $self->{ext_public_action} //= $self->default_ext_public_action; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$self->{"ext_public_action"} //= $self->default_ext_public_action
MC/DC0%0/2
$self->{"ext_public_action"} //= $self->default_ext_public_action
$self->{"ext_public_action"}
$self->default_ext_public_action
Truth table33%1/3
A //= B
A= $self->{"ext_public_action"}B= $self->default_ext_public_action
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | $self->{_handled_ext_list} = [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | $self->{ext_public}, $self->{ext_public_action} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 192 | ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 192 | $self->{_re_handled_ext} = do { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 192 | my $str = join("|", @{$self->{_handled_ext_list}}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 192 | qr{\.($str)$}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 192 | ▶ | $self->{per_role_docroot_key} ||= $self->default_per_role_docroot_key; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$self->{"per_role_docroot_key"} ||= $self->default_per_role_docroot_key
MC/DC0%0/2
$self->{"per_role_docroot_key"} ||= $self->default_per_role_docroot_key
$self->{"per_role_docroot_key"}
$self->default_per_role_docroot_key
Truth table33%1/3
A ||= B
A= $self->{"per_role_docroot_key"}B= $self->default_per_role_docroot_key
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 192 | ▶ | $self->{default_role} ||= $self->default_default_role; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$self->{"default_role"} ||= $self->default_default_role
MC/DC0%0/2
$self->{"default_role"} ||= $self->default_default_role
$self->{"default_role"}
$self->default_default_role
Truth table33%1/3
A ||= B
A= $self->{"default_role"}B= $self->default_default_role
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 192 | ▶ | $self->{config_dir} //= do { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$self->{"config_dir"} //= do {
if (not $self->{"app_root"}) {
undef;
}
elsif ($self->{"use_sibling_config_dir"}) {
qq[$self->{"app_root"}.config.d];
}
else {
qq[$self->{"app_root"}/config];
}
}
MC/DC0%0/2
$self->{"config_dir"} //= do {
if (not $self->{"app_root"}) {
undef;
}
elsif ($self->{"use_sibling_config_dir"}) {
qq[$self->{"app_root"}.config.d];
}
else {
qq[$self->{"app_root"}/config];
}
}
$self->{"config_dir"}
do {
if (not $self->{"app_root"}) {
undef;
}
elsif ($self->{"use_sibling_config_dir"}) {
qq[$self->{"app_root"}.config.d];
}
else {
qq[$self->{"app_root"}/config];
}
}
Truth table33%1/3
A //= B
A= $self->{"config_dir"}B= do {
if (not $self->{"app_root"}) {
undef;
}
elsif ($self->{"use_sibling_config_dir"}) {
qq[$self->{"app_root"}.config.d];
}
else {
qq[$self->{"app_root"}/config];
}
}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 192 | ▶ | if (not $self->{app_root}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 0 | undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | } elsif ($self->{use_sibling_config_dir}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 3 | "$self->{app_root}.config.d" | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 189 | "$self->{app_root}/config" | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 192 | $self->{_dirapp_config} = +{}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 192 | ▶ | $self->{site_config_as_entity} //= $self->default_site_config_as_entity; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$self->{"site_config_as_entity"} //= $self->default_site_config_as_entity
MC/DC0%0/2
$self->{"site_config_as_entity"} //= $self->default_site_config_as_entity
$self->{"site_config_as_entity"}
$self->default_site_config_as_entity
Truth table33%1/3
A //= B
A= $self->{"site_config_as_entity"}B= $self->default_site_config_as_entity
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 192 | ▶ | sub default_per_role_docroot_key { 'yatt.role' } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
default_per_role_docroot_key: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 192 | ▶ | sub default_default_role { 'nobody' } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
default_default_role: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 192 | ▶ | sub default_site_config_as_entity {1} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
default_site_config_as_entity: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 244 | ▶ | sub _cf_delegates { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_cf_delegates: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | (shift->SUPER::_cf_delegates | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 244 | , qw(overwrite_status_code_for_errors_as)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | #======================================== | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | # runas($type, $fh, \%ENV, \@ARGV) ... for CGI/FCGI support. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | #======================================== | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 16 | ▶ | sub runas { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
runas: called CC=3 SCAR=11.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 16 | (my $this, my $type) = splice @_, 0, 2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 16 | ▶ | my MY $self = ref $this ? $this : $this->new; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 16 | ▶ | my $sub = $self->can("runas_$type") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | or die "\n\nUnknown runas type: $type"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 16 | $sub->($self, @_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 16 | ▶ | sub runas_cgi { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
runas_cgi: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 16 | require YATT::Lite::WebMVC0::SiteApp::CGI; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 16 | shift->_runas_cgi(@_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 0 | ▶ | sub runas_fcgi { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
runas_fcgi: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 0 | require YATT::Lite::WebMVC0::SiteApp::FCGI; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 0 | shift->_runas_fcgi(@_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | # callas($type, $app, $fh, \%ENV, \@ARGV, %opts) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 0 | ▶ | sub callas { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
callas: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 0 | (my $this, my $type) = splice @_, 0, 2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 0 | ▶ | my MY $self = ref $this ? $this : $this->new; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 0 | ▶ | my $sub = $self->can("callas_$type") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | or die "\n\nUnknown callas type: $type"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 0 | $sub->($self, @_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 0 | ▶ | sub callas_cgi { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
callas_cgi: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 0 | require YATT::Lite::WebMVC0::SiteApp::CGI; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 0 | shift->_callas_cgi(@_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 0 | ▶ | sub callas_fcgi { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
callas_fcgi: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 0 | require YATT::Lite::WebMVC0::SiteApp::FCGI; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 0 | shift->_callas_fcgi(@_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | #======================================== | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | # Dispatcher::get_dirhandler | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | # -> Util::cached_in | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | # -> Factory::load | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | # -> Factory::buildspec | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 748 | ▶ | sub get_lochandler { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_lochandler: called CC=3 SCAR=15.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 748 | (my MY $self, my ($location, $tmpldir)) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 748 | ▶ | if ($self->{per_role_docroot}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | # When per_role_docroot is on, $tmpldir already points | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | # $per_role_docroot/$role. So just append $location. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | # Unfortunately, $self->error_response calls get_lochandler without $tmpldir | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 0 | ▶ | $tmpldir //= "$self->{per_role_docroot}/$self->{default_role}"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$tmpldir //= qq[$self->{"per_role_docroot"}/$self->{"default_role"}]
MC/DC0%0/1
$tmpldir //= qq[$self->{"per_role_docroot"}/$self->{"default_role"}]
$tmpldir
Truth table0%0/2
A
A= $tmpldir
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 0 | $self->get_dirhandler($tmpldir.$location); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 748 | $self->SUPER::get_lochandler($location, $tmpldir); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | #---------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | # preload_handlers | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 1 | ▶ | sub preload_apps { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
preload_apps: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 1 | (my MY $self, my (@dir)) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 1 | ▶ | push @dir, $self->{doc_root} unless @dir; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 1 | my @apps; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 1 | foreach my $dir ($self->find_apps(@dir)) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 4 | push @apps, my $app = $self->get_dirhandler($dir); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 1 | @apps; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 1 | ▶ | sub find_apps { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
find_apps: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 1 | (my MY $self, my @dir) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 1 | require File::Find; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 1 | my @apps; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 17 | ▶ | my $handler = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 17 | ▶ | push @apps, $_ if -d; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 1 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 1 | File::Find::find({wanted => $handler | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | , no_chdir => 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | , follow_skip => 2} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | , @dir | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | 1 | @apps; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | #======================================== | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | # PSGI Adaptor | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | #======================================== | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 68 | ▶ | use YATT::Lite::PSGIEnv qw/SCRIPT_URL/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 86 | ▶ | sub to_app { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
to_app: called CC=3 SCAR=13.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 86 | my MY $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | # XXX: Should check it. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | # unless (defined $self->{app_root}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | # croak "app_root is undef!"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | # } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 86 | ▶ | unless (defined $self->{doc_root} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $self->{"doc_root"} or defined $self->{"per_role_docroot"}
MC/DC0%0/2
defined $self->{"doc_root"} or defined $self->{"per_role_docroot"}
defined $self->{"doc_root"}
defined $self->{"per_role_docroot"}
Truth table33%1/3
A or B
A= defined $self->{"doc_root"}B= defined $self->{"per_role_docroot"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | or defined $self->{per_role_docroot}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 0 | croak "document_root is undef!"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 86 | return $self->SUPER::to_app(@_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 88 | ▶ | sub prepare_app { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
prepare_app: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 88 | (my MY $self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | 88 | $self->next::method; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | 88 | $self->{is_psgi} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 88 | require Plack::Request; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 88 | require Plack::Response; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | 88 | require Plack::Util; # for response_cb in call(). Do not rely on plackup. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 88 | my $backend; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 88 | ▶ | if ($backend = $self->{backend} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$backend = $self->{"backend"} and my $sub = $backend->can("startup")
MC/DC50%1/2
$backend = $self->{"backend"} and my $sub = $backend->can("startup")
$backend = $self->{"backend"}
my $sub = $backend->can("startup")
Truth table66%2/3
A and B
A= $backend = $self->{"backend"}B= my $sub = $backend->can("startup")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | and my $sub = $backend->can('startup')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | 1 | $sub->($backend, $self, $self->preload_apps); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 491 | ▶ | sub call { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
call: called CC=38 SCAR=47.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 491 | (my MY $self, my Env $env) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 491 | YATT::Lite::Breakpoint::break_psgi_call(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | 491 | ▶ | if ($self->has_htdebug("env")) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | 0 | ▶ | return $self->psgi_dump(map {"$_\t".($env->{$_}//"(undef)")."\n"} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$env->{$_} // "(undef)"
MC/DC0%0/1
$env->{$_} // "(undef)"
$env->{$_}
Truth table0%0/2
A
A= $env->{$_}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | sort keys %$env); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | 491 | ▶ | if (my $deny = $self->has_forbidden_path($env->{PATH_INFO}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$self->has_forbidden_path($env->{"PATH_INFO"}) // $self->has_forbidden_path($env->{"PATH_TRANSLATED"})
MC/DC50%1/2
$self->has_forbidden_path($env->{"PATH_INFO"}) // $self->has_forbidden_path($env->{"PATH_TRANSLATED"})
$self->has_forbidden_path($env->{"PATH_INFO"})
$self->has_forbidden_path($env->{"PATH_TRANSLATED"})
Truth table66%2/3
A // B
A= $self->has_forbidden_path($env->{"PATH_INFO"})B= $self->has_forbidden_path($env->{"PATH_TRANSLATED"})
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | // $self->has_forbidden_path($env->{PATH_TRANSLATED})) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | 3 | return $self->psgi_error(403, "Forbidden $deny"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 488 | ▶ | if (not $self->{no_unicode_params} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
not $self->{"no_unicode_params"} and $self->{"output_encoding"}
MC/DC0%0/2
not $self->{"no_unicode_params"} and $self->{"output_encoding"}
not $self->{"no_unicode_params"}
$self->{"output_encoding"}
Truth table33%1/3
not(A) and B
A= not $self->{"no_unicode_params"}B= $self->{"output_encoding"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | and $self->{output_encoding}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | $env->{PATH_INFO} = Encode::decode($self->{output_encoding} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | 488 | , $env->{PATH_INFO}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | 488 | ▶ | if ($self->{_loc2psgi_dict} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$self->{"_loc2psgi_dict"} and () = $self->lookup_psgi_mount($env->{"PATH_INFO"})
MC/DC100%2/2
$self->{"_loc2psgi_dict"} and () = $self->lookup_psgi_mount($env->{"PATH_INFO"})
$self->{"_loc2psgi_dict"}
() = $self->lookup_psgi_mount($env->{"PATH_INFO"})
Truth table100%3/3
A and B
A= $self->{"_loc2psgi_dict"}B= () = $self->lookup_psgi_mount($env->{"PATH_INFO"})
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | and my ($path_prefix, $psgi_app) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | = $self->lookup_psgi_mount($env->{PATH_INFO})) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | 7 | require Plack::Util; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | 7 | local $env->{PATH_INFO} = $self->trimleft_length($env->{PATH_INFO}, $path_prefix); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 7 | local $env->{SCRIPT_NAME} = $self->trimleft_length($env->{SCRIPT_NAME}, $path_prefix); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | 7 | return Plack::Util::run_app($psgi_app, $env); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | # XXX: user_dir? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | 481 | my ($tmpldir, $loc, $file, $trailer, $is_index, $request_file) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | = my @pi = $self->split_path_info($env); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | 481 | ▶ | if (@pi and $loc =~ m{/\.\./}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
@pi and $loc =~ m[/\.\./]
MC/DC0%0/2
@pi and $loc =~ m[/\.\./]
@pi
$loc =~ m[/\.\./]
Truth table66%2/3
A and B
A= @piB= $loc =~ m[/\.\./]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | 0 | return $self->psgi_error(403, "Bad location: $loc"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | # Set $env->{yatt.script_name} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | 481 | $self->set_yatt_script_name($env); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | 481 | my ($realdir, $virtdir); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | 481 | ▶ | if (@pi) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 478 | $realdir = "$tmpldir$loc"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | $virtdir = defined $self->{doc_root} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | 478 | ▶ | ? "$self->{doc_root}$loc" : $realdir; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | 481 | ▶ | if ($self->has_htdebug("path_info")) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | 0 | return $self->psgi_dump([tmpldir => $tmpldir] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | , [loc => $loc] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | , [file => $file] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | , [trailer => $trailer] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | , [virtdir => $virtdir, realdir => $realdir] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | 481 | ▶ | if ($self->{debug_psgi}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | # XXX: should be configurable. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | 0 | ▶ | if (my $errfh = fileno(STDERR) ? \*STDERR : $env->{'psgi.errors'}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | print $errfh join("\t" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | , "# REQ: " | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | , terse_dump([tmpldir => $tmpldir] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | , [loc => $loc] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | , [file => $file] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | , [trailer => $trailer] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | , ['all templdirs', $self->{_tmpldirs}] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | 0 | , map {[$_ => $env->{$_}]} sort keys %$env) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | ), "\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | 481 | ▶ | unless (@pi) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | 3 | return $self->psgi_handle_fallback($env); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | 478 | ▶ | unless (-d $realdir) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | 0 | return $self->psgi_error(404, "Not found: $loc"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | # Default index file. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | # Note: Files may placed under (one of) tmpldirs instead of docroot. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | 478 | ▶ | if ($file eq '') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | 0 | $file = "$self->{index_name}.$self->{ext_public}"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | } elsif ($file eq $self->{index_name}) { #XXX: $is_index | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | 0 | $file .= ".$self->{ext_public}"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | 478 | ▶ | if ($file !~ $self->{_re_handled_ext}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | 1 | ▶ | if ($self->{debug_psgi} and $self->has_htdebug("static")) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->{"debug_psgi"} and $self->has_htdebug("static")
MC/DC0%0/2
$self->{"debug_psgi"} and $self->has_htdebug("static")
$self->{"debug_psgi"}
$self->has_htdebug("static")
Truth table33%1/3
A and B
A= $self->{"debug_psgi"}B= $self->has_htdebug("static")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | return $self->psgi_dump("Not handled since extension doesn't match" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | 0 | , $file, $self->{_re_handled_ext}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | 1 | return $self->psgi_handle_static($env); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | 477 | ▶ | my $dh = $self->get_lochandler(map {untaint_any($_)} $loc, $tmpldir) or do { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | 0 | return $self->psgi_error(404, "No such directory: $loc"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | # To support $con->param and other cgi compat methods. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | 477 | my $req = Plack::Request->new($env); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | 477 | ▶ | $request_file //= $is_index ? '' : trim_ext($file, $self->{ext_public}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$request_file //= $is_index ? "" : trim_ext($file, $self->{"ext_public"})
MC/DC0%0/2
$request_file //= $is_index ? "" : trim_ext($file, $self->{"ext_public"})
$request_file
$is_index ? "" : trim_ext($file, $self->{"ext_public"})
Truth table33%1/3
A //= B
A= $request_fileB= $is_index ? "" : trim_ext($file, $self->{"ext_public"})
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | my @params = (env => $env | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | , path_info => $env->{PATH_INFO} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | 477 | ▶ | , $self->connection_quad([$virtdir, $loc, $file, $trailer | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | , $request_file]) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | , $is_index ? (is_index => 1) : () | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | , is_psgi => 1); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | 477 | local $CON = my $con = $self->make_connection(undef, @params, yatt => $dh, noheader => 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | 477 | ▶ | my $error = catch { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | 477 | $CON->configure(cgi => $req); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | 460 | $self->run_dirhandler($dh, $con, $file); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | 477 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | 477 | try_invoke($con, 'flush_headers'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | 477 | ▶ | if ($self->has_htdebug("response")) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | 0 | return [200, [], [terse_dump(["caught exception" => $error]) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | , "\n", terse_dump(["diag(inner to outer)" => $CON->diag_list]) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | , "\n", terse_dump(["buffers(inner to outer)" => $CON->oldbuf, $CON->buffer]) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | 477 | ▶ | if ($con->is_error) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | 107 | print STDERR "# EARLY ERROR\n" if DEBUG_ERROR; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | 107 | my $error_list = $con->error_list; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | 107 | return $self->error_response($error_list->[0], $env, $con); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | ▶ | elsif (not $error or is_done($error)) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
not $error or is_done($error)
MC/DC50%1/2
not $error or is_done($error)
not $error
is_done($error)
Truth table66%2/3
not(A) or B
A= not $errorB= is_done($error)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | 329 | print STDERR "# NORMAL\n" if DEBUG_ERROR; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | 329 | return $self->psgi_response_of_connection($con, $env); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | ▶ | } elsif (ref $error eq 'ARRAY' or ref $error eq 'CODE') { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
ref $error eq "ARRAY" or ref $error eq "CODE"
MC/DC0%0/2
ref $error eq "ARRAY" or ref $error eq "CODE"
ref $error eq "ARRAY"
ref $error eq "CODE"
Truth table66%2/3
A or B
A= ref $error eq "ARRAY"B= ref $error eq "CODE"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | 41 | print STDERR "# SPECIAL\n" if DEBUG_ERROR; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | # redirect | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | 41 | ▶ | if ($self->{debug_psgi}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | 0 | ▶ | if (my $errfh = fileno(STDERR) ? \*STDERR : $env->{'psgi.errors'}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | 0 | print $errfh "PSGI Response: ", terse_dump($error), "\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | 41 | ▶ | return Plack::Util::response_cb($error, sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | 41 | my $res = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | 41 | $self->finalize_response($env, $res); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | 41 | $res; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | 41 | }); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | } elsif (UNIVERSAL::isa($error, 'YATT::Lite::Error')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | 0 | print STDERR "# ERROR\n" if DEBUG_ERROR; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | 0 | return $self->error_response($error, $env, $con); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | 0 | print STDERR "# from raw die\n" if DEBUG_ERROR; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | # system_error. Should be treated by PSGI Server. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | 0 | die $error; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | 108 | ▶ | sub error_response { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
error_response: called CC=6 SCAR=18.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | 108 | (my MY $self, my $err, my Env $env, my $orig_con) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | my $error_status = $self->{overwrite_status_code_for_errors_as} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | // $err->{http_status_code} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | 108 | ▶ | // $orig_con->cget('status') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition75%6/8
(($self->{"overwrite_status_code_for_errors_as"} // $err->{"http_status_code"}) // $orig_con->cget("status")) // 500
($self->{"overwrite_status_code_for_errors_as"} // $err->{"http_status_code"}) // $orig_con->cget("status")
$self->{"overwrite_status_code_for_errors_as"} // $err->{"http_status_code"}
MC/DC33%1/3
(($self->{"overwrite_status_code_for_errors_as"} // $err->{"http_status_code"}) // $orig_con->cget("status")) // 500
$self->{"overwrite_status_code_for_errors_as"}
$err->{"http_status_code"}
$orig_con->cget("status")
Truth table50%2/4
A // B // C
A= $self->{"overwrite_status_code_for_errors_as"}B= $err->{"http_status_code"}C= $orig_con->cget("status")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | // 500; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | 108 | my $root = $self->get_lochandler('/'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | 108 | ▶ | if (my ($sub, $pkg) = $root->find_renderer(error => ignore_error => 1)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | 16 | my $errcon = $orig_con->as_error; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | 16 | local ($SYS, $CON) = ($self, $errcon); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | 16 | $sub->($pkg, $errcon, $err); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | 16 | $self->psgi_response_of_connection($errcon, $env); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | 92 | ▶ | return $self->psgi_text($err->cget('http_status_code') // 500 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$err->cget("http_status_code") // 500
MC/DC100%1/1
$err->cget("http_status_code") // 500
$err->cget("http_status_code")
Truth table100%2/2
A
A= $err->cget("http_status_code")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | , $err->byte_message); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | 345 | ▶ | sub psgi_response_of_connection { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
psgi_response_of_connection: called CC=6 SCAR=18.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | 345 | (my MY $self, my $con, my Env $env) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | 345 | ▶ | $env //= $con->cget('env'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$env //= $con->cget("env")
MC/DC0%0/2
$env //= $con->cget("env")
$env
$con->cget("env")
Truth table33%1/3
A //= B
A= $envB= $con->cget("env")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | 345 | ▶ | my $code = $con->cget('status') // $env->{REDIRECT_STATUS} // 200; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%5/5
($con->cget("status") // $env->{"REDIRECT_STATUS"}) // 200
$con->cget("status") // $env->{"REDIRECT_STATUS"}
MC/DC100%2/2
($con->cget("status") // $env->{"REDIRECT_STATUS"}) // 200
$con->cget("status")
$env->{"REDIRECT_STATUS"}
Truth table100%3/3
A // B
A= $con->cget("status")B= $env->{"REDIRECT_STATUS"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | 345 | my $res = Plack::Response->new($code); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | $res->content_type("text/html" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | . ($self->{header_charset} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | 345 | ▶ | ? qq{; charset="$self->{header_charset}"} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | : "")); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | 345 | ▶ | if (my @h = $con->list_header) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | 8 | $res->headers->header(@h); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | 345 | $res->body($con->buffer); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | 345 | my $tuple = $res->finalize; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | 345 | $self->finalize_response($env, $tuple); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | 345 | return $tuple; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | 610 | ▶ | sub before_dirhandler { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
before_dirhandler: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | 610 | (my MY $self, my ($dh, $con, $file)) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | 610 | ▶ | if ($self->{site_config_as_entity}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | 610 | $self->examine_site_config($con); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | 610 | &maybe::next::method; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | 131 | ▶ | sub make_debug_params { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
make_debug_params: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | 131 | (my MY $self, my ($reqrec, $args)) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | 131 | ▶ | my ($path_info, @rest) = ref $reqrec ? @$reqrec : $reqrec; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | 131 | my Env $env = Env->psgi_simple_env; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | 131 | $env->{PATH_INFO} = $path_info; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | 131 | $env->{REQUEST_URI} = $path_info; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | 131 | my @params = ($self->SUPER::make_debug_params($reqrec, $args) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | , env => $env); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | 131 | require Plack::Request; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | 131 | push @params, cgi => Plack::Request->new($env) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | , parameters => YATT::Lite::Util::ixhash(lexpand($args)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | , is_psgi => 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | ; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | 131 | @params; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | #======================================== | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | 1 | ▶ | sub psgi_handle_static { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
psgi_handle_static: called CC=2 SCAR=7.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | 1 | (my MY $self, my Env $env) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | my $app = $self->{psgi_static} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | 1 | ▶ | || $self->psgi_file_app($self->{doc_root}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$self->{'psgi_static'} || $self->psgi_file_app($self->{'doc_root'})
MC/DC0%0/2
$self->{'psgi_static'} || $self->psgi_file_app($self->{'doc_root'})
$self->{'psgi_static'}
$self->psgi_file_app($self->{'doc_root'})
Truth table33%1/3
A || B
A= $self->{'psgi_static'}B= $self->psgi_file_app($self->{'doc_root'})
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | # When PATH_INFO contains virtual path prefix (like /~$user/), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | # we need to strip them (for Plack::App::File). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | 1 | local $env->{PATH_INFO} = $self->trim_site_prefix($env->{PATH_INFO}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | 1 | $app->($env); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | 3 | ▶ | sub psgi_handle_fallback { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
psgi_handle_fallback: called CC=3 SCAR=11.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | 3 | (my MY $self, my Env $env) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | (my $app = $self->{psgi_fallback} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | ||= $self->psgi_file_app($self->{doc_root})) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | 3 | ▶ | or return [404, [], ["Cannot understand: ", $env->{PATH_INFO}]]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$self->{"psgi_fallback"} ||= $self->psgi_file_app($self->{"doc_root"})
MC/DC0%0/2
$self->{"psgi_fallback"} ||= $self->psgi_file_app($self->{"doc_root"})
$self->{"psgi_fallback"}
$self->psgi_file_app($self->{"doc_root"})
Truth table66%2/3
A ||= B
A= $self->{"psgi_fallback"}B= $self->psgi_file_app($self->{"doc_root"})
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | 3 | local $env->{PATH_INFO} = $self->trim_site_prefix($env->{PATH_INFO}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | 3 | $app->($env); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | 4 | ▶ | sub trim_site_prefix { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
trim_site_prefix: called CC=2 SCAR=7.6
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | 4 | (my MY $self, my $path) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | 4 | ▶ | if (my $pfx = $self->{site_prefix}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | 0 | substr($path, length($pfx)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | 4 | $path; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | # XXX: Do we need to care about following headers too?: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | # * X-Content-Security-Policy | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | # * X-Request-With | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | # * X-Frame-Options | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | # * Strict-Transport-Security | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | #======================================== | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | 500 | ▶ | sub set_yatt_script_name { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_yatt_script_name: called CC=8 SCAR=21.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | 500 | (my MY $self, my Env $env) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | 500 | my $script_name = $env->{'yatt.script_name'} = do { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | 500 | ▶ | if (not $self->{no_trim_script_name} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition63%7/11
not $self->{"no_trim_script_name"} and $env->{"REDIRECT_HANDLER"} and ($env->{"REDIRECT_STATUS"} // 0) == 200 and $env->{"SCRIPT_FILENAME"}
not $self->{"no_trim_script_name"} and $env->{"REDIRECT_HANDLER"} and ($env->{"REDIRECT_STATUS"} // 0) == 200
not $self->{"no_trim_script_name"} and $env->{"REDIRECT_HANDLER"}
$env->{"REDIRECT_STATUS"} // 0
MC/DC25%1/4
not $self->{"no_trim_script_name"} and $env->{"REDIRECT_HANDLER"} and ($env->{"REDIRECT_STATUS"} // 0) == 200 and $env->{"SCRIPT_FILENAME"}
not $self->{"no_trim_script_name"}
$env->{"REDIRECT_HANDLER"}
$env->{"REDIRECT_STATUS"}
$env->{"SCRIPT_FILENAME"}
Truth table40%2/5
not(A) and B and C and D
A= not $self->{"no_trim_script_name"}B= $env->{"REDIRECT_HANDLER"}C= $env->{"REDIRECT_STATUS"}D= $env->{"SCRIPT_FILENAME"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | and $env->{REDIRECT_HANDLER} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | and ($env->{REDIRECT_STATUS} // 0) == 200 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | and $env->{SCRIPT_FILENAME} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | # For Apache Action+AddHandler mapping. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | trim_common_suffix_from($env->{SCRIPT_NAME} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | 27 | , $env->{SCRIPT_FILENAME}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | # Normal case. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | 473 | ▶ | my $copy = $env->{SCRIPT_NAME} // ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$env->{"SCRIPT_NAME"} // ""
MC/DC100%1/1
$env->{"SCRIPT_NAME"} // ""
$env->{"SCRIPT_NAME"}
Truth table100%2/2
A
A= $env->{"SCRIPT_NAME"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | 473 | $copy =~ s,/+\z,,; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | 473 | $copy; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | # script_dir = script_name + / | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | 500 | ▶ | ($env->{'yatt.script_dir'} = $script_name // '') =~ s,/*\z,/,; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$script_name // ""
MC/DC0%0/1
$script_name // ""
$script_name
Truth table50%1/2
A
A= $script_name
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | 500 | $script_name | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 549 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | 497 | ▶ | sub split_path_info { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
split_path_info: called CC=16 SCAR=30.6
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 551 | 497 | (my MY $self, my Env $env) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 553 | 497 | ▶ | if (! $self->{per_role_docroot} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition66%4/6
not $self->{"per_role_docroot"} and nonempty($env->{"PATH_TRANSLATED"}) and $self->is_path_translated_mode($env)
not $self->{"per_role_docroot"} and nonempty($env->{"PATH_TRANSLATED"})
MC/DC33%1/3
not $self->{"per_role_docroot"} and nonempty($env->{"PATH_TRANSLATED"}) and $self->is_path_translated_mode($env)
not $self->{"per_role_docroot"}
nonempty($env->{"PATH_TRANSLATED"})
$self->is_path_translated_mode($env)
Truth table50%2/4
not(A) and B and C
A= not $self->{"per_role_docroot"}B= nonempty($env->{"PATH_TRANSLATED"})C= $self->is_path_translated_mode($env)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | && nonempty($env->{PATH_TRANSLATED}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | && $self->is_path_translated_mode($env)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 557 | # [1] PATH_TRANSLATED mode. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | # If REDIRECT_STATUS == 200 and PATH_TRANSLATED is not empty, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | # use it as a template path. It must be located under app_root. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 561 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | # In this case, PATH_TRANSLATED should be valid physical path | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 563 | # + optionally trailing sub path_info. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 564 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 565 | # XXX: What should be done when app_root is empty? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 566 | # XXX: Is userdir ok? like /~$USER/dir? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | # XXX: should have cut_depth option. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 568 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 569 | my ($tmpldir, $loc, $file, $trailer, $is_index, $request_file) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 570 | = split_path($env->{PATH_TRANSLATED}, $self->{app_root} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 571 | , $self->{use_subpath} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 572 | , $self->{ext_public} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 573 | 35 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 574 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 575 | # This is a workaround for $is_index. Determining $is_index only from | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 576 | # PATH_TRANSLATED was just wrong. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 577 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 578 | # So instead turn on it when "$env->{REQUEST_URI}$file" eq $env->{REDIRECT_URL}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 579 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 580 | 35 | ▶ | $is_index ||= do { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$is_index ||= do {
if ($env->{"REQUEST_URI"} and $env->{"REDIRECT_URL"}) {
my $path = "URI"->new($env->{"REQUEST_URI"})->path;
"$path$file" eq $env->{"REDIRECT_URL"};
}
}
MC/DC50%1/2
$is_index ||= do {
if ($env->{"REQUEST_URI"} and $env->{"REDIRECT_URL"}) {
my $path = "URI"->new($env->{"REQUEST_URI"})->path;
"$path$file" eq $env->{"REDIRECT_URL"};
}
}
$is_index
do {
if ($env->{"REQUEST_URI"} and $env->{"REDIRECT_URL"}) {
my $path = "URI"->new($env->{"REQUEST_URI"})->path;
"$path$file" eq $env->{"REDIRECT_URL"};
}
}
Truth table66%2/3
A ||= B
A= $is_indexB= do {
if ($env->{"REQUEST_URI"} and $env->{"REDIRECT_URL"}) {
my $path = "URI"->new($env->{"REQUEST_URI"})->path;
"$path$file" eq $env->{"REDIRECT_URL"};
}
}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 581 | 35 | ▶ | if ($env->{REQUEST_URI} and $env->{REDIRECT_URL}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$env->{"REQUEST_URI"} and $env->{"REDIRECT_URL"}
MC/DC50%1/2
$env->{"REQUEST_URI"} and $env->{"REDIRECT_URL"}
$env->{"REQUEST_URI"}
$env->{"REDIRECT_URL"}
Truth table66%2/3
A and B
A= $env->{"REQUEST_URI"}B= $env->{"REDIRECT_URL"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 582 | 24 | my $path = URI->new($env->{REQUEST_URI})->path; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 583 | 24 | "$path$file" eq $env->{REDIRECT_URL}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 584 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 585 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 586 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 587 | # GH-251: Likewise, PATH_TRANSLATED alone can not tell whether the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 588 | # request spelled the file name with or without the extension | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 589 | # (Apache MultiViews may have completed it). So correct | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 590 | # $request_file by selecting the candidate which matches | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 591 | # REQUEST_URI. Note: this only *selects* from known-safe | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 592 | # candidates and never takes substrings of REQUEST_URI itself. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 593 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 594 | 35 | ▶ | if ($is_index) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 595 | 16 | $request_file = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 596 | ▶ | } elsif (nonempty($env->{REQUEST_URI}) and nonempty($file)) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
nonempty($env->{"REQUEST_URI"}) and nonempty($file)
MC/DC0%0/2
nonempty($env->{"REQUEST_URI"}) and nonempty($file)
nonempty($env->{"REQUEST_URI"})
nonempty($file)
Truth table33%1/3
A and B
A= nonempty($env->{"REQUEST_URI"})B= nonempty($file)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 597 | 19 | my $req_path = URI->new($env->{REQUEST_URI})->path; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 598 | 19 | ▶ | $req_path =~ s{\Q$trailer\E\z}{} if nonempty($trailer); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 599 | 19 | foreach my $cand ($file, trim_ext($file, $self->{ext_public})) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 600 | 29 | ▶ | next unless $req_path =~ m{/\Q$cand\E\z}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 601 | 19 | $request_file = $cand; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 602 | 19 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 603 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 604 | # When no candidate matches (e.g. rewritten request), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 605 | # $request_file from PATH_TRANSLATED is kept as-is. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 606 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 607 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 608 | 35 | ($tmpldir, $loc, $file, $trailer, $is_index, $request_file); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 609 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 610 | } elsif (nonempty($env->{PATH_INFO})) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 611 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 612 | # [2] Template lookup mode. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 613 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 614 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 615 | 462 | my $tmpldirs = do { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 616 | 462 | ▶ | if ($self->{per_role_docroot}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 617 | 0 | my $user = $env->{$self->{per_role_docroot_key}}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 618 | 0 | ▶ | $user ||= $self->{default_role}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$user ||= $self->{"default_role"}
MC/DC0%0/2
$user ||= $self->{"default_role"}
$user
$self->{"default_role"}
Truth table0%0/3
A ||= B
A= $userB= $self->{"default_role"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 619 | 0 | ["$self->{per_role_docroot}/$user"] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 620 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 621 | $self->{_tmpldirs} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 622 | 462 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 623 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 624 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 625 | lookup_path($env->{PATH_INFO} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 626 | , $tmpldirs | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 627 | , $self->{index_name} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 628 | , $self->{_handled_ext_list} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 629 | 462 | , $self->{use_subpath}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 630 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 631 | # or die | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 632 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 633 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 634 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 635 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 636 | 979 | ▶ | sub has_forbidden_path { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
has_forbidden_path: called CC=4 SCAR=13.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 637 | 979 | (my MY $self, my $path) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 638 | 979 | ▶ | if (not defined $path) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 639 | 461 | return undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 640 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 641 | elsif ($path =~ m{\.lib(?: / | $ )}x) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 642 | 1 | return ".lib: $path"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 643 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 644 | elsif ($path =~ m{(?:^|/)\.ht|\.ytmpl$ }x) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 645 | # XXX: basename() is just to ease testing. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 646 | 2 | return "filetype: " . basename($path); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 647 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 648 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 649 | 515 | undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 650 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 651 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 652 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 653 | 35 | ▶ | sub is_path_translated_mode { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_path_translated_mode: called CC=2 SCAR=7.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 654 | 35 | (my MY $self, my Env $env) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 655 | 35 | ▶ | ($env->{REDIRECT_STATUS} // 0) == 200 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$env->{"REDIRECT_STATUS"} // 0
MC/DC0%0/1
$env->{"REDIRECT_STATUS"} // 0
$env->{"REDIRECT_STATUS"}
Truth table50%1/2
A
A= $env->{"REDIRECT_STATUS"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 656 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 657 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 658 | # XXX: kludge! redundant! | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 659 | 2 | ▶ | sub split_path_url { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
split_path_url: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 660 | 2 | (my MY $self, my ($path_translated, $path_info, $document_root)) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 661 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 662 | 2 | my @info = do { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 663 | 2 | ▶ | if ($path_info =~ s{^(/~[^/]+)(?=/)}{}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 664 | 1 | my $user = $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 665 | 1 | my ($root, $loc, $file, $trailer) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 666 | = split_path($path_translated | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 667 | , substr($path_translated, 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 668 | , length($path_translated) - length($path_info)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 669 | , 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 670 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 671 | 1 | (dir => "$root$loc", file => $file, subpath => $trailer | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 672 | , root => $root, location => "$user$loc"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 673 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 674 | 1 | my ($root, $loc, $file, $trailer) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 675 | = split_path($path_translated, $document_root, 0); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 676 | 1 | (dir => "$root$loc", file => $file, subpath => $trailer | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 677 | , root => $root, location => $loc); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 678 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 679 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 680 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 681 | 2 | ▶ | if (wantarray) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 682 | @info | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 683 | 0 | } else { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 684 | 2 | my %info = @info; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 685 | 2 | \%info; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 686 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 687 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 688 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 689 | # どこを起点に split_path するか。UserDir の場合は '' を返す。 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 690 | 0 | ▶ | sub document_dir { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
document_dir: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 691 | 0 | (my MY $self, my $cgi) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 692 | 0 | my $path_info = $cgi->path_info; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 693 | 0 | ▶ | if (my ($user) = $path_info =~ m{^/~([^/]+)/}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 694 | 0 | ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 695 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 696 | 0 | ▶ | $self->{doc_root} // ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->{"doc_root"} // ""
MC/DC0%0/1
$self->{"doc_root"} // ""
$self->{"doc_root"}
Truth table0%0/2
A
A= $self->{"doc_root"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 697 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 698 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 699 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 700 | #======================================== | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 701 | 6 | ▶ | sub is_debug_allowed { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_debug_allowed: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 702 | 6 | (my MY $self, my Env $env) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 703 | 6 | ▶ | return unless $self->{_allow_debug_from}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 704 | 5 | ▶ | return unless defined(my $ip = $self->guess_client_ip($env)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 705 | 5 | $self->is_debug_allowed_ip($ip); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 706 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 707 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 708 | 63 | ▶ | sub is_debug_allowed_ip { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_debug_allowed_ip: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 709 | 63 | (my MY $self, my $ip) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 710 | 63 | ▶ | $self->configure_allow_debug_from unless $self->{_allow_debug_from}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 711 | 63 | $self->{_allow_debug_from}->($ip); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 712 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 713 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 714 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 715 | # The address of the client, for is_debug_allowed. Proxy headers | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 716 | # (X-Real-IP, X-Client-IP, X-Forwarded-For) are written by whoever | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 717 | # sends the request, so they are believed only when the peer | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 718 | # (REMOTE_ADDR) is one of the configured trusted_proxies. Without that | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 719 | # config this is just REMOTE_ADDR. X-Forwarded-For is read from the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 720 | # right: the rightmost hop not in trusted_proxies is the client; values | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 721 | # to the left of it may have been planted by the client itself. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 722 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 723 | 44 | ▶ | sub guess_client_ip { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
guess_client_ip: called CC=9 SCAR=22.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 724 | 44 | (my MY $self, my Env $env) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 725 | 44 | my $remote = $env->{REMOTE_ADDR}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 726 | 44 | ▶ | return $remote unless defined $remote and $self->is_trusted_proxy($remote); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $remote and $self->is_trusted_proxy($remote)
MC/DC50%1/2
defined $remote and $self->is_trusted_proxy($remote)
defined $remote
$self->is_trusted_proxy($remote)
Truth table66%2/3
A and B
A= defined $remoteB= $self->is_trusted_proxy($remote)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 727 | 18 | foreach my $direct ($env->{HTTP_X_REAL_IP}, $env->{HTTP_X_CLIENT_IP}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 728 | 30 | ▶ | return $direct if defined $direct and $direct ne ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $direct and $direct ne ""
MC/DC50%1/2
defined $direct and $direct ne ""
defined $direct
$direct ne ""
Truth table66%2/3
A and B
A= defined $directB= $direct ne ""
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 729 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 730 | 11 | ▶ | if (defined(my $forward = $env->{HTTP_X_FORWARDED_FOR})) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 731 | 9 | foreach my $hop (reverse grep {$_ ne ''} split /\s*,\s*/, ($forward =~ s/^\s+|\s+$//gr)) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 732 | 12 | ▶ | return $hop unless $self->is_trusted_proxy($hop); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 733 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 734 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 735 | 4 | $remote; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 736 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 737 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 738 | 56 | ▶ | sub is_trusted_proxy { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_trusted_proxy: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 739 | 56 | (my MY $self, my $ip) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 740 | my $matcher = $self->{_trusted_proxies} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 741 | 56 | ▶ | or return 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 742 | 35 | $matcher->($ip); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 743 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 744 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 745 | 68 | *configure_debug_allowed_ip = *configure_allow_debug_from; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 746 | 68 | *configure_debug_allowed_ip = *configure_allow_debug_from; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 747 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 748 | 18 | ▶ | sub configure_allow_debug_from { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
configure_allow_debug_from: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 749 | 18 | (my MY $self, my $data) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 750 | $self->{_allow_debug_from} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 751 | 18 | ▶ | = $self->compile_addr_matcher(allow_debug_from => $data // ['127.0.0.1', '::1']); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$data // ["127.0.0.1", "::1"]
MC/DC100%1/1
$data // ["127.0.0.1", "::1"]
$data
Truth table100%2/2
A
A= $data
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 752 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 753 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 754 | 6 | ▶ | sub configure_trusted_proxies { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
configure_trusted_proxies: called CC=2 SCAR=7.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 755 | 6 | (my MY $self, my $data) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 756 | $self->{_trusted_proxies} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 757 | 6 | ▶ | = defined $data ? $self->compile_addr_matcher(trusted_proxies => $data) : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 758 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 759 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 760 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 761 | # Build a predicate sub for an address list. The default compares the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 762 | # address as a whole string, exactly (no parsing, no extra module, to | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 763 | # keep CGI startup cheap). YATT::Lite::WebMVC0::Partial::StrictIPMatch | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 764 | # overrides this to parse addresses and accept CIDR ranges. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 765 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 766 | 12 | ▶ | sub compile_addr_matcher { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
compile_addr_matcher: called CC=3 SCAR=11.7
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 767 | 12 | (my MY $self, my ($name, $list)) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 768 | 12 | ▶ | my @items = grep {defined $_ and $_ ne ''} lexpand($list); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
defined $_ && $_ ne ''
MC/DC0%0/2
defined $_ && $_ ne ''
defined $_
$_ ne ''
Truth table33%1/3
A && B
A= defined $_B= $_ ne ''
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 769 | 0 | ▶ | return sub { 0 } unless @items; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 770 | 12 | my $pat = join "|", map { quotemeta($_) } @items; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 771 | 12 | my $re = qr{^(?:$pat)\z}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 772 | 12 | ▶ | sub { defined $_[0] and $_[0] =~ $re }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.2
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 773 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 774 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 775 | 1514 | ▶ | sub has_htdebug { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
has_htdebug: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 776 | 1514 | (my MY $self, my $name) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 777 | 1514 | my $envName = uc("htdebug_$name"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 778 | 1514 | ▶ | if (exists $ENV{$envName}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 779 | 2 | return $ENV{$envName}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 780 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 781 | defined $self->{app_root} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 782 | 1512 | ▶ | and -e "$self->{app_root}/.htdebug_$name" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 783 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 784 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 785 | #======================================== | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 786 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 787 | #======================================== | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 788 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 789 | 68 | ▶ | use YATT::Lite::WebMVC0::Connection; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 790 | sub Connection () {'YATT::Lite::WebMVC0::Connection'} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 791 | sub ConnProp () {Connection} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 792 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 793 | 678 | ▶ | sub make_connection { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
make_connection: called CC=8 SCAR=27.7
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 794 | 678 | (my MY $self, my ($fh, @args)) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 795 | 678 | my @opts = do { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 796 | 678 | ▶ | if ($self->{noheader}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 797 | # direct mode. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 798 | 0 | ($fh, noheader => 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 799 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 800 | # buffered mode. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 801 | 678 | (undef, parent_fh => $fh); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 802 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 803 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 804 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 805 | 678 | push @opts, site_prefix => $self->{site_prefix}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 806 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 807 | 678 | ▶ | if (my $fn = $self->{logfile}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 808 | 0 | my $dir = $self->app_path_ensure_existing(dirname($fn)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 809 | 0 | my $real = "$dir/" . basename($fn); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 810 | 0 | ▶ | open my $fh, '>>', $real or die "Can't open logfile: fn=$real: $!"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 811 | 0 | push @opts, logfh => $fh; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 812 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 813 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 814 | push @opts, debug => $self->{debug_connection} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 815 | 678 | ▶ | if $self->{debug_connection}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 816 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 817 | 678 | ▶ | if (my $back = $self->{backend}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 818 | 0 | ▶ | push @opts, (backend => try_invoke($back, 'clone') // $back); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
try_invoke($back, "clone") // $back
MC/DC0%0/2
try_invoke($back, "clone") // $back
try_invoke($back, "clone")
$back
Truth table0%0/3
A // B
A= try_invoke($back, "clone")B= $back
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 819 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 820 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 821 | 678 | ▶ | if (my $enc = $$self{output_encoding}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 822 | 678 | push @opts, encoding => $enc; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 823 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 824 | $self->SUPER::make_connection | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 825 | (@opts | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 826 | 678 | , $self->cf_delegate_defined(qw(is_psgi | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 827 | no_unicode_params | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 828 | no_nested_query | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 829 | mkquery_with_body_params)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 830 | , @args); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 831 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 832 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 833 | 386 | ▶ | sub finalize_response { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
finalize_response: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 834 | 386 | shift->next::method(@_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 835 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 836 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 837 | # This will be called back from $CON->flush_heades. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 838 | 678 | ▶ | sub finalize_connection { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
finalize_connection: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 839 | 678 | my MY $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 840 | 678 | my ConnProp $prop = (my $glob = shift)->prop; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 841 | 678 | ▶ | $self->session_flush($glob) if $prop->{_session}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 842 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 843 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 844 | #======================================== | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 845 | # misc. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 846 | #======================================== | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 847 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 848 | 0 | ▶ | sub header_charset { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
header_charset: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 849 | 0 | (my MY $self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 850 | 0 | ▶ | $self->{header_charset} || $self->{output_encoding}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 851 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 852 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 853 | #======================================== | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 854 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 855 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 856 | # Alternative dir_config under $app_root/config/$app_name.{yml,xhf} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 857 | # Note: $app_name may contain '/'. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 858 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 859 | 0 | ▶ | sub dirapp_config_for { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
dirapp_config_for: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 860 | 0 | (my MY $self, my $yatt_or_app_name) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 861 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 862 | 0 | ▶ | unless ($self->{config_dir}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 863 | 0 | Carp::croak "config_dir is empty!"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 864 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 865 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 866 | 0 | my $app_name = do { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 867 | 0 | ▶ | if (not ref $yatt_or_app_name) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 868 | 0 | $yatt_or_app_name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 869 | } elsif ($self->{use_sibling_config_dir}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 870 | 0 | $yatt_or_app_name->rel_app_name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 871 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 872 | 0 | $yatt_or_app_name->app_name | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 873 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 874 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 875 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 876 | 0 | my $base_path = "$self->{config_dir}/$app_name"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 877 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 878 | 0 | ▶ | my $has_latest_entry = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 879 | 0 | my ($dict, $key) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 880 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 881 | 0 | ▶ | defined (my $prev_entry = $dict->{$key}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 882 | or return undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 883 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 884 | 0 | my ($age, $path, $obj) = @$prev_entry; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 885 | 0 | ▶ | my $new_age = -M $path or do { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 886 | 0 | delete $dict->{$key}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 887 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 888 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 889 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 890 | 0 | ▶ | $new_age == $age | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 891 | or return undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 892 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 893 | 0 | $prev_entry; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 894 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 895 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 896 | 0 | ▶ | if (my $prev_entry = $has_latest_entry->($self->{_dirapp_config}, $base_path)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 897 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 898 | 0 | $prev_entry->[-1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 899 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 900 | } elsif (my $cf = $self->find_unique_config_file($base_path)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 901 | 0 | my $obj = $self->read_file($cf); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 902 | 0 | $self->{_dirapp_config}{$base_path} = [-M $cf, $cf, $obj]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 903 | 0 | $obj; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 904 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 905 | 0 | undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 906 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 907 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 908 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 909 | 2 | ▶ | sub site_config { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
site_config: called CC=2 SCAR=7.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 910 | 2 | (my MY $self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 911 | 2 | ▶ | $self->{site_config} // do { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$self->{"site_config"} // do {
$self->examine_site_config;
$self->{"site_config"}
}
MC/DC0%0/2
$self->{"site_config"} // do {
$self->examine_site_config;
$self->{"site_config"}
}
$self->{"site_config"}
do {
$self->examine_site_config;
$self->{"site_config"}
}
Truth table33%1/3
A // B
A= $self->{"site_config"}B= do {
$self->examine_site_config;
$self->{"site_config"}
}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 912 | 2 | $self->examine_site_config; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 913 | 2 | $self->{site_config}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 914 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 915 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 916 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 917 | 620 | ▶ | sub examine_site_config { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
examine_site_config: called CC=8 SCAR=20.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 918 | 620 | (my MY $self, my $con) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 919 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 920 | 620 | ▶ | if ($con) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 921 | # Cache should be examined at most once for each request. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 922 | 618 | my ConnProp $prop = $con->prop; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 923 | 618 | ▶ | return if $prop->{_site_config_is_examined}++; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 924 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 925 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 926 | 612 | ▶ | if (my $cache_entry = $self->{_site_config_cache_entry}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 927 | 8 | my ($age, $fn) = @$cache_entry; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 928 | 8 | my $cur_age = -M $fn; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 929 | 8 | ▶ | if (not defined $cur_age) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 930 | # Cached file is deleted, so cache should be deleted too. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 931 | 0 | delete $self->{_site_config_cache_entry}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 932 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 933 | } elsif ($age == $cur_age) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 934 | # Cache is valid. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 935 | 4 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 936 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 937 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 938 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 939 | # Examine app.site_config.{yml,xhf} and site_config.{yml,xhf}. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 940 | my ($cf) = ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 941 | ($self->{use_sibling_config_dir} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 942 | ? $self->find_unique_config_file($self->{config_dir}, "/site_config") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 943 | : ()), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 944 | # Note: $self->{app_rootname} and $self->{app_root} can be undef | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 945 | # but find_unique_config_file() can safely ignore undef. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 946 | $self->find_unique_config_file($self->{app_rootname}, ".site_config"), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 947 | 608 | ▶ | $self->find_unique_config_file($self->{app_root}, "/site_config"), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 948 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 949 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 950 | 608 | ▶ | if ($cf) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 951 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 952 | 10 | $self->{site_config} = $self->read_file($cf); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 953 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 954 | 10 | $self->{_site_config_cache_entry} = [-M $cf, $cf]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 955 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 956 | 10 | $self->site_config_load_hook; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 957 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 958 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 959 | 598 | $self->{site_config} = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 960 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 961 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 962 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 963 | 10 | ▶ | sub site_config_load_hook { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
site_config_load_hook: called CC=4 SCAR=13.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 964 | 10 | (my MY $self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 965 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 966 | 10 | ▶ | if ($self->{site_config_as_entity}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 967 | 10 | my $entns = $self->EntNS; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 968 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 969 | 10 | foreach my $name (keys %{$self->{site_config}}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 970 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 971 | 26 | ▶ | next if $name =~ /\W/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 972 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 973 | 16 | ▶ | $self->add_entity_into($entns, $name, sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 974 | 16 | my MY $actual = $SYS; # To avoid directly capturing $self. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 975 | 16 | $actual->{site_config}{$name}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 976 | 18 | }, 1); # Just ignore if already defined. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 977 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 978 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 979 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 980 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 981 | #======================================== | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 982 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 983 | 8 | ▶ | Entity site_config => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 984 | 8 | my ($this, $name, $default) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 985 | 8 | my MY $self = $SYS; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 986 | 8 | $SYS->examine_site_config($CON); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 987 | 8 | ▶ | return $self->{site_config} unless defined $name; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 988 | 4 | ▶ | $self->{site_config}{$name} // $default; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$self->{"site_config"}{$name} // $default
MC/DC0%0/2
$self->{"site_config"}{$name} // $default
$self->{"site_config"}{$name}
$default
Truth table33%1/3
A // B
A= $self->{"site_config"}{$name}B= $default
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 989 | 68 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 990 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 991 | 21 | ▶ | Entity is_debug_allowed_ip => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 992 | 21 | my ($this, $remote_addr) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 993 | 21 | my MY $self = $SYS; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 994 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 995 | 21 | ▶ | $remote_addr //= do { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$remote_addr //= do {
my YATT::Lite::WebMVC0::SiteApp::Env $env = $YATT::Lite::WebMVC0::SiteApp::CON->env;
$self->guess_client_ip($env)
}
MC/DC0%0/2
$remote_addr //= do {
my YATT::Lite::WebMVC0::SiteApp::Env $env = $YATT::Lite::WebMVC0::SiteApp::CON->env;
$self->guess_client_ip($env)
}
$remote_addr
do {
my YATT::Lite::WebMVC0::SiteApp::Env $env = $YATT::Lite::WebMVC0::SiteApp::CON->env;
$self->guess_client_ip($env)
}
Truth table66%2/3
A //= B
A= $remote_addrB= do {
my YATT::Lite::WebMVC0::SiteApp::Env $env = $YATT::Lite::WebMVC0::SiteApp::CON->env;
$self->guess_client_ip($env)
}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 996 | 18 | my Env $env = $CON->env; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 997 | 18 | $self->guess_client_ip($env); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 998 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 999 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1000 | 21 | ▶ | $remote_addr && $self->is_debug_allowed_ip($remote_addr) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1001 | 68 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1002 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1003 | 68 | foreach my $name (qw/ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1004 | file_location | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1005 | page_location | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1006 | dir_location | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1007 | is_current_file | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1008 | is_current_page | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1009 | file_page | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1010 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1011 | site_path | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1012 | site_url | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1013 | current_path | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1014 | current_url | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1015 | raise_redirect | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1016 | / | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1017 | ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1018 | 748 | my $method = $name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1019 | 662 | ▶ | Entity $method => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1020 | 662 | shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1021 | 662 | $CON->$method(@_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1022 | 748 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1023 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1024 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1025 | 68 | foreach my $item (map([$_ => uc($_)] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1026 | , qw/path_info | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1027 | request_uri | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1028 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1029 | script_filename | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1030 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1031 | SCRIPT_NAME | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1032 | SCRIPT_URI | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1033 | SCRIPT_URL | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1034 | /)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1035 | 408 | my ($method, $env_name) = @$item; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1036 | 0 | ▶ | Entity $method => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1037 | 0 | my Env $env = $CON->env; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1038 | 0 | $env->{$env_name}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1039 | 408 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1040 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1041 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1042 | # &yatt:SCRIPT_NAME(); is original $env->{SCRIPT_NAME} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1043 | # &yatt:script_name(); is $env->{'yatt.script_name'} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1044 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1045 | 15 | ▶ | Entity script_name => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1046 | 15 | my ($this) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1047 | 15 | my Env $env = $CON->env; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1048 | 15 | $env->{'yatt.script_name'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1049 | 68 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1050 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1051 | 0 | ▶ | Entity script_dir => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1052 | 0 | my ($this) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1053 | 0 | my Env $env = $CON->env; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1054 | 0 | $env->{'yatt.script_dir'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1055 | 68 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1056 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1057 | # GH-205 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1058 | # &yatt:SCRIPT_URI(); is original $env->{SCRIPT_URI} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1059 | # &yatt:script_uri(); cares HTTP_X_FORWARDED_PROTO | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1060 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1061 | 4 | ▶ | Entity script_uri => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1062 | 4 | my ($this) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1063 | 4 | $CON->mkprefix . $this->entity_script_url; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1064 | 68 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1065 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1066 | 4 | ▶ | Entity script_url => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.6
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1067 | 4 | my ($this) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1068 | 4 | my Env $env = $CON->env; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1069 | 4 | ▶ | $env->{SCRIPT_URL} // $this->entity_file_location; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$env->{"SCRIPT_URL"} // $this->entity_file_location
MC/DC0%0/2
$env->{"SCRIPT_URL"} // $this->entity_file_location
$env->{"SCRIPT_URL"}
$this->entity_file_location
Truth table33%1/3
A // B
A= $env->{"SCRIPT_URL"}B= $this->entity_file_location
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1070 | 68 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1071 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1072 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1073 | # :abspath() - location + file | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1074 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1075 | 4 | ▶ | Entity abspath => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.7
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1076 | 4 | my ($this) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1077 | 4 | my ConnProp $prop = $CON->prop; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1078 | 4 | ▶ | ($prop->{location} // '').($prop->{file} // ''); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%2/4
$prop->{"location"} // ""
$prop->{"file"} // ""
MC/DC0%0/1
$prop->{"location"} // ""
$prop->{"location"}
MC/DC0%0/1
$prop->{"file"} // ""
$prop->{"file"}
Truth table50%1/2
A
A= $prop->{"location"}
Truth table50%1/2
A
A= $prop->{"file"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1079 | 68 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1080 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1081 | 0 | ▶ | Entity abspath_in_siteapp => sub {shift->entity_abspath}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1082 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1083 | # :absrequest() - REQUEST_URI - yatt.script_name | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1084 | # Note: since this value is derived from REQUEST_URI, which do not contain | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1085 | # index.yatt typically, this is not suitable to get physical filename. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1086 | 4 | ▶ | Entity absrequest => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1087 | 4 | my ($this) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1088 | 4 | my Env $env = $CON->env; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1089 | 4 | my $url = substr($env->{REQUEST_URI}, length $env->{'yatt.script_name'}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1090 | 4 | $url =~ s{\?.*}{}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1091 | 4 | $url; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1092 | 68 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1093 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1094 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1095 | #======================================== | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1096 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1097 | 68 | YATT::Lite::Breakpoint::break_load_dispatcher(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1098 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1099 | 68 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||