Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eli007s/3c6f35565fedfdcf0dc2000dd65f7bd0 to your computer and use it in GitHub Desktop.
Save eli007s/3c6f35565fedfdcf0dc2000dd65f7bd0 to your computer and use it in GitHub Desktop.
nginx-unzip-module, NODIR, NOCASE mod
diff --git a/ngx_http_unzip_module.c b/ngx_http_unzip_module.c
index 771e1dc..00ea0f1 100644
--- a/nginx-unzip-module/ngx_http_unzip_module.c
+++ b/nginx-unzip-module/ngx_http_unzip_module.c
@@ -224,7 +224,7 @@ static ngx_int_t ngx_http_unzip_handler(ngx_http_request_t *r)
zip_stat_init(&zip_st);
/* let's check what's the size of a file. return 404 if we can't stat file inside archive */
- if (0 != zip_stat(zip_source, unzipextract_path, 0, &zip_st)) {
+ if (0 != zip_stat(zip_source, unzipextract_path, ZIP_FL_NODIR|ZIP_FL_NOCASE, &zip_st)) {
ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, "no file %s inside %s archive.", unzipextract_path, unzipfile_path);
free(unzipfile_path);
free(unzipextract_path);
@@ -245,7 +245,7 @@ static ngx_int_t ngx_http_unzip_handler(ngx_http_request_t *r)
* try to open a file that we want - if not return 500 as we know that the file is there (making zip_stat before)
* so let's return 500.
*/
- if (!(file_in_zip = zip_fopen(zip_source, unzipextract_path, 0))) {
+ if (!(file_in_zip = zip_fopen(zip_source, unzipextract_path, ZIP_FL_NODIR|ZIP_FL_NOCASE))) {
ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, "failed to open %s from %s archive (corrupted?).",
unzipextract_path, unzipfile_path);
free(unzipfile_path);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment