Tatsuki SUGIURA
sugi****@users*****
2006年 7月 12日 (水) 20:41:38 JST
Index: slashjp/Slash/Custom/ApacheSSI/ApacheSSI.pm diff -u slashjp/Slash/Custom/ApacheSSI/ApacheSSI.pm:1.1 slashjp/Slash/Custom/ApacheSSI/ApacheSSI.pm:1.2 --- slashjp/Slash/Custom/ApacheSSI/ApacheSSI.pm:1.1 Wed Dec 22 18:13:33 2004 +++ slashjp/Slash/Custom/ApacheSSI/ApacheSSI.pm Wed Jul 12 20:41:38 2006 @@ -1,7 +1,7 @@ # This code is a part of Slash, and is released under the GPL. -# Copyright 1997-2004 by Open Source Development Network. See README +# Copyright 1997-2005 by Open Source Technology Group. See README # and COPYING for more information, or see http://slashcode.com/. -# $Id: ApacheSSI.pm,v 1.1 2004/12/22 09:13:33 oliver Exp $ +# $Id: ApacheSSI.pm,v 1.2 2006/07/12 11:41:38 sugi Exp $ # this merely overrides a "broken" method in Apache::SSI, # where include directives don't work for mixing with Apache::Compress @@ -16,9 +16,25 @@ use base 'Apache::SSI'; use vars qw($VERSION); -use Apache::Constants qw(:common OPT_INCNOEXEC); +use Apache::Constants qw(:common :http OPT_INCNOEXEC); -($VERSION) = ' $Revision: 1.1 $ ' =~ /\$Revision:\s+([^\s]+)/; +($VERSION) = ' $Revision: 1.2 $ ' =~ /\$Revision:\s+([^\s]+)/; + +sub output { + my $self = shift; + + my @parts = split m/(<!--#.*?-->)/s, $self->{'text'}; + while (@parts) { +# $self->{_r}->print( ('', shift @parts)[1-$self->{'suspend'}[0]] ); + print( ('', shift @parts)[1-$self->{'suspend'}[0]] ); + last unless @parts; + my $ssi = shift @parts; + if ($ssi =~ m/^<!--#(.*)-->$/s) { +# $self->{_r}->print( $self->output_ssi($1) ); + print( $self->output_ssi($1) ); + } else { die 'Parse error' } + } +} sub ssi_perl { my($self, $args, $margs) = @_; @@ -41,17 +57,16 @@ $self->error("Include of ", $subr->filename, " failed: $!"); } } else { - unless ($subr->run == OK) { - $self->error("Include of '@{[$subr->filename()]}' failed: $!"); + if ( $subr->status == HTTP_OK ) { + # Subrequests can fuck up %ENV, make sure it's restored upon exit. + # Unfortunately 'local(%ENV)=%ENV' reportedly causes segfaults. + my %save_ENV = %ENV; + $subr->run == OK + or $self->error("Include of '@{[$subr->filename()]}' failed: $!"); + %ENV = %save_ENV; } } - ## Make sure that all of the variables set in the include are present here. - #my $env = $subr->subprocess_env(); - #foreach ( keys %$env ) { - # $self->{_r}->subprocess_env($_, $env->{$_}); - #} - return ''; }