Skip to content

Commit

Permalink
Fix check for arguments to fancyindex_{header,footer}
Browse files Browse the repository at this point in the history
Closes #117
  • Loading branch information
aperezdc committed Oct 26, 2020
1 parent 4fc6bb1 commit c33b05a
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 8 deletions.
2 changes: 1 addition & 1 deletion ngx_http_fancyindex_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion t/08-local-footer.test
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
2 changes: 1 addition & 1 deletion t/09-local-header.test
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
4 changes: 2 additions & 2 deletions t/10-local-headerfooter.test
Original file line number Diff line number Diff line change
Expand Up @@ -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 /)

Expand Down
6 changes: 3 additions & 3 deletions t/11-local-footer-nested.test
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
11 changes: 11 additions & 0 deletions t/12-local-footer-nested.test
Original file line number Diff line number Diff line change
@@ -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'

0 comments on commit c33b05a

Please sign in to comment.