Skip to content

Commit 4e3db6e

Browse files
committed
protect against load a dir
1 parent f2a113c commit 4e3db6e

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

lib/Plack/Util.pm

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,9 @@ sub _load_sandbox {
121121
package Plack::Sandbox::%s;
122122
{
123123
my $app = do $_file;
124-
if ( !$app && ( my $error = $@ || $! )) { die $error; }
124+
if ( !$app && ( my $error = $@ || $! || "returned invalid value.\n")) {
125+
die $error;
126+
}
125127
$app;
126128
}
127129
END_EVAL

t/Plack-Util/load.t

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,13 @@ use Test::More;
4545
unlike $@, qr/Died/;
4646
}
4747

48+
{
49+
eval { Plack::Util::load_psgi("t/Plack-Util/") };
50+
# Perl 5.20+ gives "Did you try to load a directory",
51+
# <=5.18 "No such file or directory"
52+
like $@, qr/Error while loading/;
53+
}
54+
4855
{
4956
my $app = Plack::Util::load_psgi("t/Plack-Util/bin/findbin.psgi");
5057
test_psgi $app, sub {

0 commit comments

Comments
 (0)