Skip to content

Commit

Permalink
Don't allow saving to filenames starting with '.' suggested by server
Browse files Browse the repository at this point in the history
  • Loading branch information
gisle committed Jan 11, 2010
1 parent 0d33cd8 commit f97f339
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion bin/lwp-download
Expand Up @@ -138,7 +138,9 @@ my $res = $ua->request(HTTP::Request->new(GET => $url),
# validate that we don't have a harmful filename now. The server
# might try to trick us into doing something bad.
if (!length($file) ||
$file =~ s/([^a-zA-Z0-9_\.\-\+\~])/sprintf "\\x%02x", ord($1)/ge)
$file =~ s/([^a-zA-Z0-9_\.\-\+\~])/sprintf "\\x%02x", ord($1)/ge ||
$file =~ /^\./
)
{
die "Will not save <$url> as \"$file\".\nPlease override file name on the command line.\n";
}
Expand Down

0 comments on commit f97f339

Please sign in to comment.