Fix directory-index-handling - quark - quark web server
 (HTM) git clone git://git.suckless.org/quark
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) LICENSE
       ---
 (DIR) commit 87ae2e9212c5cc7309eefa2a3f49a758862db6c7
 (DIR) parent f3b6d5efc375bedd287897dcaabffec7f9222ea6
 (HTM) Author: Laslo Hunhold <dev@frign.de>
       Date:   Sun, 24 Jan 2021 18:37:03 +0100
       
       Fix directory-index-handling
       
       Previously, quark would properly check for the docindex-path, but not
       actually change the response-struct accordingly. I missed this during
       the restructurization of the code.
       
       Thanks to Quentin Rameau for spotting this issue! This commit is based
       on his patch.
       
       Signed-off-by: Laslo Hunhold <dev@frign.de>
       
       Diffstat:
         M http.c                              |       9 ++++++++-
       
       1 file changed, 8 insertions(+), 1 deletion(-)
       ---
 (DIR) diff --git a/http.c b/http.c
       @@ -760,6 +760,13 @@ http_prepare_response(const struct request *req, struct response *res,
                                            S_FORBIDDEN : S_NOT_FOUND;
                                        goto err;
                                }
       +                } else {
       +                        /* docindex is valid, write tmpuri to response-path */
       +                        if (esnprintf(res->path, sizeof(res->path), "%s",
       +                                      tmpuri)) {
       +                                s = S_REQUEST_TOO_LARGE;
       +                                goto err;
       +                        }
                        }
                }
        
       @@ -800,7 +807,7 @@ http_prepare_response(const struct request *req, struct response *res,
        
                /* mime */
                mime = "application/octet-stream";
       -        if ((p = strrchr(realuri, '.'))) {
       +        if ((p = strrchr(res->path, '.'))) {
                        for (i = 0; i < LEN(mimes); i++) {
                                if (!strcmp(mimes[i].ext, p + 1)) {
                                        mime = mimes[i].type;