lighttpd: Fix trailing slash on files in mod_dirlisting

Fixes [YOCTO #16128]

Backport of upstream bug fix from lighttpd-1.4.75. Version 1.4.74 introduced a bug that
would append a trailing slash to files in a directory listing. When the user attempts to
download one of these files, the web browser could not save the file with a trailing
slash. As a consequence, every web browser tested would generate a random character string
for the saved file name.

(From OE-Core rev: 797f15116901328a9a58868edeea44614dc29043)

Signed-off-by: Fred Bacon <bacon@aerodyne.com>
[Yoann: Fixed Upstream-Status: Backport URL]
Signed-off-by: Yoann Congal <yoann.congal@smile.fr>
Signed-off-by: Paul Barker <paul@pbarker.dev>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Fred Bacon
2026-01-20 10:57:48 -05:00
committed by Richard Purdie
parent 7ba5e4b416
commit c7084e7f05
2 changed files with 49 additions and 0 deletions

View File

@@ -0,0 +1,48 @@
From 3d400ce06dcb950a61363f87330324db244f4bac Mon Sep 17 00:00:00 2001
From: Glenn Strauss <gstrauss@gluelogic.com>
Date: Thu, 29 Feb 2024 20:59:57 -0500
Subject: [PATCH] [mod_dirlisting] fix suffix display of '/' on file (fixes
#3242)
fix incorrect suffix display of '/' on files
(regression in lighttpd 1.4.74)
(thx guy)
Upstream-Status: Backport [https://github.com/lighttpd/lighttpd1.4/commit/3d400ce06dcb950a61363f87330324db244f4bac]
References:
[1] https://redmine.lighttpd.net/issues/3242
Signed-off-by: Glenn Strauss <gstrauss@gluelogic.com>
---
src/mod_dirlisting.c | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/src/mod_dirlisting.c b/src/mod_dirlisting.c
index a3432211..2686cd3e 100644
--- a/src/mod_dirlisting.c
+++ b/src/mod_dirlisting.c
@@ -1022,10 +1022,19 @@ static void http_list_directory_dirname(buffer * const out, const dirls_entry_t
buffer_append_string_len(out, CONST_STR_LEN("</td><td class=\"s\">- &nbsp;</td><td class=\"t\">Directory</td></tr>\n"));
}
+static void http_list_file_ent(buffer * const out, const dirls_entry_t * const ent, const char * const name) {
+ buffer_append_string_encoded(out, name, ent->namelen, ENCODING_REL_URI_PART);
+ buffer_append_string_len(out, CONST_STR_LEN("\">"));
+ buffer_append_string_encoded(out, name, ent->namelen, ENCODING_MINIMAL_XML);
+ buffer_append_string_len(out, CONST_STR_LEN("</a></td><td class=\"m\">"));
+
+ http_list_directory_mtime(out, ent);
+}
+
static void http_list_directory_filename(buffer * const out, const dirls_entry_t * const ent, const char * const name, handler_ctx * const hctx) {
buffer_append_string_len(out, CONST_STR_LEN("<tr><td class=\"n\"><a href=\""));
- http_list_directory_ent(out, ent, name);
+ http_list_file_ent(out, ent, name);
const buffer *content_type;
#if defined(HAVE_XATTR) || defined(HAVE_EXTATTR) /*(pass full path)*/

View File

@@ -14,6 +14,7 @@ SRC_URI = "http://download.lighttpd.net/lighttpd/releases-1.4.x/lighttpd-${PV}.t
file://index.html.lighttpd \
file://lighttpd.conf \
file://lighttpd \
file://0001-mod_dirlisting.patch \
"
SRC_URI[sha256sum] = "5c08736e83088f7e019797159f306e88ec729abe976dc98fb3bed71b9d3e53b5"