Skip to content

Commit

Permalink
Fixed an issue with "+" in the filename
Browse files Browse the repository at this point in the history
  • Loading branch information
dup2 committed Sep 19, 2013
1 parent 6f71b11 commit 3c69ff5
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 3 deletions.
4 changes: 2 additions & 2 deletions ngx_http_zip_parsers.c
Expand Up @@ -49,12 +49,12 @@ destructive_url_decode_len(unsigned char* start, unsigned char* end)

for (; read_pos < end; read_pos++) {
unsigned char ch = *read_pos;
if (ch == '+')
ch = ' ';
if (ch == '%' && (read_pos+2 < end)) {
ch = 16 * hex_char_value(*(read_pos+1)) + hex_char_value(*(read_pos+2));
read_pos += 2;
}
if (ch == '+')
ch = ' ';
*(write_pos++) = ch;
}

Expand Down
1 change: 1 addition & 0 deletions t/nginx/html/file1 with space + plus.txt
@@ -0,0 +1 @@
This is the first file.
2 changes: 2 additions & 0 deletions t/nginx/html/zip-spaces-plus.txt
@@ -0,0 +1,2 @@
1a6349c5 24 /file1%20with%20space%20%2B%20plus.txt file1.txt
5d70c4d3 25 /file2.txt file2.txt
9 changes: 8 additions & 1 deletion t/ziptest.pl
Expand Up @@ -2,7 +2,7 @@

# TODO tests for Zip64

use Test::More tests => 84;
use Test::More tests => 88;
use LWP::UserAgent;
use Archive::Zip;

Expand Down Expand Up @@ -137,6 +137,13 @@ ($$)
$zip = test_zip_archive($response->content, "with spaces in URLs");
is($zip->numberOfMembers(), 2, "Correct number in spaced-out ZIP");

$response = $ua->get("$http_root/zip-spaces-plus.txt");
is($response->code, 200, "Returns OK with spaces and plus in URLs");

$zip = test_zip_archive($response->content, "with spaces and plus in the URLs");
is($zip->numberOfMembers(), 2, "Correct number in spaces and plus ZIP");


open LARGEFILE, ">", "nginx/html/largefile.txt";
for (0..99999) {
print LARGEFILE "X" x 99;
Expand Down

0 comments on commit 3c69ff5

Please sign in to comment.