1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
|
Description: Fixes broken charset parsing in do_dir and
send_error functions which results in a literal
charset=%s getting passed to the browser.
Author: Alexandru Mihail, alexandru.mihail2897@gmail.com
Origin: maintainer
Last-Update: 2024-03-30
---
This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
--- a/mini_httpd.c
+++ b/mini_httpd.c
@@ -1677,7 +1677,6 @@
<html>\n\
\n\
<head>\n\
- <meta http-equiv=\"Content-type\" content=\"text/html;charset=UTF-8\">\n\
<title>Index of %s</title>\n\
</head>\n\
\n\
@@ -1730,7 +1729,7 @@
SERVER_URL, SERVER_SOFTWARE );
add_str( &contents, &contents_size, &contents_len, buf );
- add_headers( 200, "Ok", "", "", "text/html; charset=%s", contents_len, sb.st_mtime );
+ add_headers( 200, "Ok", "", "", "text/html; charset=UTF-8", contents_len, sb.st_mtime );
if ( method != METHOD_HEAD )
{
contents[contents_len] = '\0';
@@ -2475,9 +2474,12 @@
static void
send_error( int s, char* title, char* extra_header, char* text )
{
+ char fixed_mime_type[500];
+ (void) snprintf(
+ fixed_mime_type, sizeof(fixed_mime_type), "text/html;charset=%s", charset );
add_headers(
- s, title, extra_header, "", "text/html; charset=%s", (off_t) -1, (time_t) -1 );
-
+ s, title, extra_header, "", fixed_mime_type, (off_t) -1,
+(time_t) -1 );
send_error_body( s, title, text );
send_error_tail();
@@ -2521,7 +2523,6 @@
<html>\n\
\n\
<head>\n\
- <meta http-equiv=\"Content-type\" content=\"text/html;charset=UTF-8\">\n\
<title>%d %s</title>\n\
</head>\n\
\n\
|