diff --git a/ngx_http_zip_parsers.c b/ngx_http_zip_parsers.c index fd9de2b..513b639 100644 --- a/ngx_http_zip_parsers.c +++ b/ngx_http_zip_parsers.c @@ -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; } diff --git a/t/nginx/html/file1 with space + plus.txt b/t/nginx/html/file1 with space + plus.txt new file mode 100644 index 0000000..5495a4f --- /dev/null +++ b/t/nginx/html/file1 with space + plus.txt @@ -0,0 +1 @@ +This is the first file. diff --git a/t/nginx/html/zip-spaces-plus.txt b/t/nginx/html/zip-spaces-plus.txt new file mode 100644 index 0000000..9589e22 --- /dev/null +++ b/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 diff --git a/t/ziptest.pl b/t/ziptest.pl index faf213d..7f05a3b 100755 --- a/t/ziptest.pl +++ b/t/ziptest.pl @@ -2,7 +2,7 @@ # TODO tests for Zip64 -use Test::More tests => 84; +use Test::More tests => 88; use LWP::UserAgent; use Archive::Zip; @@ -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;