Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
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