Fix check for arguments to fancyindex_{header,footer}

Closes #117
pull/122/head
Adrian Perez de Castro 2020-10-26 22:32:21 +02:00 committed by Adrian Perez
parent 4fc6bb10d7
commit c33b05af9e
6 changed files with 19 additions and 8 deletions

View File

@ -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,

View File

@ -9,7 +9,7 @@ cat > "${TESTDIR}/footer" <<EOF
<div id="customfooter">yes</div>
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'

View File

@ -9,7 +9,7 @@ cat > "${TESTDIR}/header" <<EOF
<div id="customheader">yes</div>
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'

View File

@ -12,8 +12,8 @@ cat > "${TESTDIR}/footer" <<EOF
<div id="customfooter">yes</div>
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 /)

View File

@ -14,10 +14,10 @@ use pup
echo '<div id="topfooter">yes</div>' > "${TESTDIR}/top-footer"
echo '<div id="subfooter">yes</div>' > "${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"

View File

@ -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'