Skip to content
This repository
Browse code

Support for UTF-8 file names.

Thanks to Robbie Scott/Bandcamp
  • Loading branch information...
commit 4f61592b9481c4f9a160bd59dbe42204c7c3d7b2 1 parent db7c1e3
authored
8  ngx_http_zip_file.c
@@ -64,7 +64,7 @@ static ngx_zip_data_descriptor_zip64_t ngx_zip_data_descriptor_zip64_template =
64 64
 static ngx_zip_local_file_header_t ngx_zip_local_file_header_template = {
65 65
     0x04034b50,  /* local file header signature */
66 66
     0x0a,        /* version needed to extract */
67  
-    0x08,        /* general purpose bit flag */
  67
+    zip_utf8_flag | zip_missing_crc32_flag,        /* general purpose bit flag */
68 68
     0,           /* compression method */
69 69
     0,           /* last mod file date/time */
70 70
     0,           /* crc-32 */
@@ -79,7 +79,7 @@ static ngx_zip_central_directory_file_header_t ngx_zip_central_directory_file_he
79 79
     0x02014b50,  /* central file header signature */
80 80
     zip_version_zip64,      /* version made by */
81 81
     zip_version_default,        /* version needed to extract */
82  
-    0x08,        /* general purpose bit flag */
  82
+    zip_utf8_flag | zip_missing_crc32_flag,        /* general purpose bit flag */
83 83
     0,           /* compression method */
84 84
     0,           /* last mod file time */
85 85
     0,           /* crc-32 */
@@ -277,7 +277,7 @@ ngx_http_zip_file_header_chain_link(ngx_http_request_t *r, ngx_http_zip_ctx_t *c
277 277
     }
278 278
 
279 279
     if (!file->missing_crc32) {
280  
-        local_file_header.flags = 0;
  280
+        local_file_header.flags &= ~zip_missing_crc32_flag;
281 281
         local_file_header.crc32 = file->crc32;
282 282
     }
283 283
 
@@ -435,7 +435,7 @@ ngx_http_zip_write_central_directory_entry(u_char *p, ngx_http_zip_file_t *file,
435 435
     if (!file->need_zip64_offset)
436 436
         central_directory_file_header.offset = file->offset;
437 437
     if (!file->missing_crc32)
438  
-        central_directory_file_header.flags = 0;
  438
+        central_directory_file_header.flags &= ~zip_missing_crc32_flag;
439 439
 
440 440
     if (file->need_zip64) {
441 441
         central_directory_file_header.version_needed = zip_version_zip64;
2  ngx_http_zip_file_format.h
@@ -7,6 +7,8 @@
7 7
 
8 8
 #define zip_version_default 10
9 9
 #define zip_version_zip64 45
  10
+#define zip_utf8_flag 0x0800
  11
+#define zip_missing_crc32_flag 0x08
10 12
 
11 13
 typedef struct {
12 14
     uint16_t   tag; //0x5455
7  t/nginx/conf/nginx.conf
@@ -3,7 +3,7 @@
3 3
 worker_processes  1;
4 4
 
5 5
 #error_log  logs/error.log;
6  
-error_log  logs/error.log  debug;
  6
+error_log  logs/error-if-range.log  debug;
7 7
 #error_log  logs/error.log  notice;
8 8
 #error_log  logs/error.log  info;
9 9
 
@@ -47,7 +47,9 @@ http {
47 47
         }
48 48
 
49 49
         location /zip {
50  
-            add_header X-Archive-Files              zip;
  50
+            add_header X-Archive-Files  zip;
  51
+            add_header Last-Modified    "Wed, 15 Nov 1995 04:58:08 GMT";
  52
+            add_header ETag             "3.14159";
51 53
         } 
52 54
     }
53 55
 
@@ -68,7 +70,6 @@ http {
68 70
 
69 71
         location /local {
70 72
             alias       html;
71  
-            index       index.html index.htm;
72 73
         }
73 74
 
74 75
         #error_page  404              /404.html;

0 notes on commit 4f61592

Please sign in to comment.
Something went wrong with that request. Please try again.