CGI must add a Content-Type header which is mandatory.
Headers must be separated from body by two CRLF (here was only one).
We also should set a charset because by default it will be Latin1.
It's better to assume that system uses UTF8.
We set "Content-Type: text/html;charset=UTF-8" header.
But it will be better to include the <META charset="UTF-8"> directly into 
generated HTML so we won't be lost it when HTML file is saved on disk.

Signed-off-by: Sergey Ponomarev <[email protected]>
---
 networking/httpd_indexcgi.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/networking/httpd_indexcgi.c b/networking/httpd_indexcgi.c
index 548f982ef..3e8094034 100644
--- a/networking/httpd_indexcgi.c
+++ b/networking/httpd_indexcgi.c
@@ -307,9 +307,10 @@ int main(int argc, char *argv[])
        qsort(dir_list, dir_list_count, sizeof(dir_list[0]), (void*)compare_dl);
 
        fmt_str(
-               "" /* Additional headers (currently none) */
-               "\r\n" /* Mandatory empty line after headers */
-               "<html><head><title>Index of ");
+               "Content-Type: text/html"
+               "\r\n\r\n" /* Mandatory empty lines after headers */
+               "<html><head><meta charset=\"UTF-8\">"
+               "<title>Index of ");
        /* Guard against directories with &, > etc */
        fmt_html(location);
        fmt_str(
-- 
2.30.2

_______________________________________________
busybox mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/busybox

Reply via email to