Apache-ASP
view release on metacpan or search on metacpan
if(&config($self, 'CgiDoSelf')) {
$data =~ s,^(.*?)__END__,,so;
}
# do both before and after, so =pods can span includes with =pods
if($self->{pod_comments}) {
&PodComments($self, \$data);
}
# if compiling includes, then do now before includes conversion
# each include will also have its Script_OnParse run on it.
if($self->{compile_includes} && $self->{GlobalASA}{'exists'}) {
$self->{Server}{ScriptRef} = \$data;
$self->{GlobalASA}->ExecuteEvent('Script_OnParse');
}
# do includes as early as possible !! so included text gets done too
# this section is for file includes, we do this here instead of ssi
# so it can be parsed and compiled with the script
local %includes; # trap recursive includes with this
# JUST ONCE
# there should only be one of these, <%@ LANGUAGE="PerlScript" %>, rip it out
# we keep white space and substitue text in so the perlscript sync's up with lines
# only take out the first one
$data =~ s/^\#\![^\n]+(\n\s*)/\<\%$1\%\>/s; #X cgi compat ?
$data =~ s/^(\s*)\<\%(\s*)\@([^\n]*?)\%\>/$1\<\%$2 ; \%\>/so;
my $root_file = $file;
my $line1_added = 0;
my $munge = $data;
$data = '';
my($file_context, $file_line_number, $code_block);
while($munge =~ s/^(.*?)\<!--\#include\s+file\s*=\s*\"?([^\s\"]*?)\"?(\s+args\s*=\s*\"?.*?)?\"?\s*--\>//so) {
$data .= $1; # append the head
my $file = $2;
# only need all this if we are in inline include mode
my $head_data;
if (! $self->{compile_includes}) {
$head_data = $1;
unless($line1_added) {
$line1_added = 1;
$head_data = ($file_exists ? "<% \n#line 1 $root_file\n %>" : '').$head_data;
}
if ($head_data =~ s/.*\n\#line (\d+) ([^\n]+)\n(\%\>)?//s) {
$file_line_number = $1;
$file_context = $2;
$code_block = $3 ? 0 : 1;
}
$file_line_number += $head_data =~ s/\n//sg;
$head_data =~ s/\<\%.*?\%\>//sg;
# print STDERR "HEAD: $head_data\n";
my $code_blocks_open = $head_data =~ s/\<\%//sg;
my $code_blocks_closed = $head_data =~ s/\%\>//sg;
$code_block += $code_blocks_open;
$code_block -= $code_blocks_closed;
if (($code_block < 0)) {
$code_block = 0; # stray percents like height=100%> kinds of tags
}
# print STDERR "CODEBLOCK: $code_block $file; open $code_blocks_open closed $code_blocks_closed\n";
# print STDERR "FILE CONTEXT: $file_context LINENO: $file_line_number\n\n";
}
# compiled include args handling
my $has_args = $3;
my $args = undef;
if($has_args) {
$args = $has_args;
$args =~ s/^\s+args\s*\=\s*\"?//sgo;
}
# global directory, as well as includes dirs
my $include = &SearchDirs($self, $file);
unless(defined $include) {
$self->Error("include file with name $file does not exist");
return;
}
if($self->{dbg}) {
if($include ne $file) {
$self->{dbg} && $self->Debug("found $file at $include");
}
}
# trap the includes here, at 100 levels like perl debugger
if(defined($args) || $self->{compile_includes}) {
# because the script is literally different whether there
# are includes or not, whether we are compiling includes
# need to be part of the script identifier, so the global
# caching does not return a script with different preferences.
$args ||= '';
$self->{dbg} && $self->Debug("runtime exec of dynamic include $file args (".
($args).')');
$data .= "<% \$Response->Include('$include', $args); %>";
# compile include now, so Loading() works for dynamic includes too
unless($self->CompileInclude($include)) {
$self->Error("compiling include $include failed when compiling script");
}
} else {
$self->{dbg} && $self->Debug("inlining include $include");
# DEFAULT, not compile includes, or inline includes,
# the included text is inlined directly into the script
if($includes{$include}++ > 100) {
$self->Error("Recursive include detected for $include 100 levels deep! ".
"Your includes are including each other. If you ".
"are getting this error with a legitimate use of includes ".
"please mail support about this error "
);
return;
}
# put the included text into what we are parsing, allows for
# includes having includes
if ($file_exists && $parse_file) {
$self->{parse_inline_count}++;
$self->{dbg} && $self->Debug("include $include found for file $parse_file");
$Apache::ASP::Includes{$parse_file}->{$include} = time();
( run in 1.000 second using v1.01-cache-2.11-cpan-39bf76dae61 )