From c33b05af9eb0b2a00b22a9604ae764517d912078 Mon Sep 17 00:00:00 2001 From: Adrian Perez de Castro Date: Mon, 26 Oct 2020 22:32:21 +0200 Subject: [PATCH] Fix check for arguments to fancyindex_{header,footer} Closes #117 --- ngx_http_fancyindex_module.c | 2 +- t/08-local-footer.test | 2 +- t/09-local-header.test | 2 +- t/10-local-headerfooter.test | 4 ++-- t/11-local-footer-nested.test | 6 +++--- t/12-local-footer-nested.test | 11 +++++++++++ 6 files changed, 19 insertions(+), 8 deletions(-) create mode 100644 t/12-local-footer-nested.test diff --git a/ngx_http_fancyindex_module.c b/ngx_http_fancyindex_module.c index d9530d1..9d7665e 100644 --- a/ngx_http_fancyindex_module.c +++ b/ngx_http_fancyindex_module.c @@ -230,7 +230,7 @@ ngx_fancyindex_conf_set_headerfooter(ngx_conf_t *cf, ngx_command_t *cmd, void *c /* Kind of path. Default is "subrequest". */ ngx_uint_t kind = NGX_HTTP_FANCYINDEX_HEADERFOOTER_SUBREQUEST; - if (cf->args->nelts == 2) { + if (cf->args->nelts == 3) { kind = headerfooter_kind(&values[2]); if (kind == NGX_CONF_UNSET_UINT) { ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, diff --git a/t/08-local-footer.test b/t/08-local-footer.test index 56f1d02..6d6318b 100644 --- a/t/08-local-footer.test +++ b/t/08-local-footer.test @@ -9,7 +9,7 @@ cat > "${TESTDIR}/footer" <yes EOF -nginx_start 'fancyindex_footer "/footer" local;' +nginx_start "fancyindex_footer \"${TESTDIR}/footer\" local;" T=$(fetch / | pup -p body 'div#customfooter' text{}) [[ $T == yes ]] || fail 'Custom header missing' diff --git a/t/09-local-header.test b/t/09-local-header.test index ac1358b..455b966 100644 --- a/t/09-local-header.test +++ b/t/09-local-header.test @@ -9,7 +9,7 @@ cat > "${TESTDIR}/header" <yes EOF -nginx_start 'fancyindex_header "/header" local;' +nginx_start "fancyindex_header \"${TESTDIR}/header\" local;" T=$(fetch / | pup -p body 'div#customheader' text{}) [[ $T == yes ]] || fail 'Custom header missing' diff --git a/t/10-local-headerfooter.test b/t/10-local-headerfooter.test index 0750d1b..6adfb45 100644 --- a/t/10-local-headerfooter.test +++ b/t/10-local-headerfooter.test @@ -12,8 +12,8 @@ cat > "${TESTDIR}/footer" <yes EOF -nginx_start 'fancyindex_header "/header" local; - fancyindex_footer "/footer" local;' +nginx_start "fancyindex_header \"${TESTDIR}/header\" local; + fancyindex_footer \"${TESTDIR}/footer\" local;" P=$(fetch /) diff --git a/t/11-local-footer-nested.test b/t/11-local-footer-nested.test index b259290..0530853 100644 --- a/t/11-local-footer-nested.test +++ b/t/11-local-footer-nested.test @@ -14,10 +14,10 @@ use pup echo '
yes
' > "${TESTDIR}/top-footer" echo '
yes
' > "${TESTDIR}/sub-footer" -nginx_start 'fancyindex_footer "/top-footer" local; +nginx_start "fancyindex_footer \"${TESTDIR}/top-footer\" local; location /child-directory { - fancyindex_footer "/sub-footer" local; - }' + fancyindex_footer \"${TESTDIR}/sub-footer\" local; + }" T=$(fetch /) echo "$T" > "$TESTDIR/top.html" diff --git a/t/12-local-footer-nested.test b/t/12-local-footer-nested.test new file mode 100644 index 0000000..7c0aef7 --- /dev/null +++ b/t/12-local-footer-nested.test @@ -0,0 +1,11 @@ +#! /bin/bash +cat <<--- +This test checks that the configuration file is properly parsed if there +is only one parameter passed to the fancyndex_header and fancyindex_footer +configuration directives. +-- + +nginx_start 'fancyindex_header "/header"; + fancyindex_footer "/footer";' + +nginx_is_running || fail 'Nginx died'