use File::Path qw( rmtree );
use File::Glob qw( bsd_glob );
use File::Spec::Unix;
+use HTTP::Message::PSGI;
+use HTTP::Request;
+use HTTP::Response;
sub DefaultHandlerArgs { (
comp_root => [
@_
);
- $handler->interp->set_escape( h => \&RT::Interface::Web::EscapeUTF8 );
+ $handler->interp->set_escape( h => \&RT::Interface::Web::EscapeHTML );
$handler->interp->set_escape( u => \&RT::Interface::Web::EscapeURI );
$handler->interp->set_escape( j => \&RT::Interface::Web::EscapeJS );
return($handler);
=item Clean up state of RT::Action::SendEmail using 'CleanSlate' method
-=item Flush tmp GnuPG key preferences
+=item Flush tmp crypt key preferences
=back
require RT::Action::SendEmail;
RT::Action::SendEmail->CleanSlate;
- if (RT->Config->Get('GnuPG')->{'Enable'}) {
- require RT::Crypt::GnuPG;
- RT::Crypt::GnuPG::UseKeyForEncryption();
- RT::Crypt::GnuPG::UseKeyForSigning( undef );
+ if (RT->Config->Get('Crypt')->{'Enable'}) {
+ RT::Crypt->UseKeyForEncryption();
+ RT::Crypt->UseKeyForSigning( undef );
}
%RT::Ticket::MERGE_CACHE = ( effective => {}, merged => {} );
+ %RT::User::PREFERENCES_CACHE = ();
# RT::System persists between requests, so its attributes cache has to be
# cleared manually. Without this, for example, subject tags across multiple
use RT::Interface::Web::Handler;
use CGI::Emulate::PSGI;
+use Plack::Builder;
use Plack::Request;
use Plack::Response;
use Plack::Util;
$self->InitSessionDir;
- return sub {
+ my $mason = sub {
my $env = shift;
{
sub {
$self->CleanupRequest()
});
-};
+ };
+ return $self->StaticWrap($mason);
+}
+
+sub StaticWrap {
+ my $self = shift;
+ my $app = shift;
+ my $builder = Plack::Builder->new;
+
+ for my $static ( RT->Config->Get('StaticRoots') ) {
+ if ( ref $static && ref $static eq 'HASH' ) {
+ $builder->add_middleware(
+ 'Plack::Middleware::Static',
+ pass_through => 1,
+ %$static
+ );
+ }
+ else {
+ $RT::Logger->error(
+ "Invalid config StaticRoots: item can only be a hashref" );
+ }
+ }
+
+ for my $root (RT::Interface::Web->StaticRoots) {
+ $builder->add_middleware(
+ 'Plack::Middleware::Static',
+ path => sub { s!^/static/!! },
+ root => $root,
+ pass_through => 1,
+ );
+ }
+ return $builder->to_app($app);
+}
sub _psgi_response_cb {
my $self = shift;
return $_[0];
};
});
- }
+}
+
+sub GetStatic {
+ my $class = shift;
+ my $path = shift;
+ my $static = $class->StaticWrap(
+ # Anything the static wrap doesn't handle gets 404'd.
+ sub { [404, [], []] }
+ );
+ my $response = HTTP::Response->from_psgi(
+ $static->( HTTP::Request->new(GET => $path)->to_psgi )
+ );
+ return $response;
}
1;