Skip to content

Commit

Permalink
Properly indicate UTF-8 charset in HTML and JSON HTTP responses
Browse files Browse the repository at this point in the history
  • Loading branch information
Jalle19 committed Aug 7, 2024
1 parent ff5985f commit e6d0be4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/minisatip.c
Original file line number Diff line number Diff line change
Expand Up @@ -1594,7 +1594,7 @@ int read_http(sockets *s) {
int len =
get_json_state(buf, JSON_STATE_MAXLEN, sbuf, JSON_STRING_MAXLEN);
http_response(s, 200,
"Content-Type: application/json\r\n"
"Content-Type: application/json; charset=utf-8\r\n"
"Connection: close\r\n"
"Access-Control-Allow-Origin: *",
buf, 0, len);
Expand All @@ -1607,7 +1607,7 @@ int read_http(sockets *s) {
char *buf = _malloc(JSON_BANDWIDTH_MAXLEN);
int len = get_json_bandwidth(buf, JSON_BANDWIDTH_MAXLEN);
http_response(s, 200,
"Content-Type: application/json\r\n"
"Content-Type: application/json; charset=utf-8\r\n"
"Connection: close\r\n"
"Access-Control-Allow-Origin: *",
buf, 0, len);
Expand Down
4 changes: 2 additions & 2 deletions src/utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -487,12 +487,12 @@ char *readfile(char *fn, char *ctype, int *len) {
"text/javascript\r\nConnection: close");
else if (endswith(fn, "htm") || endswith(fn, "html"))
strcpy(ctype, "Cache-Control: max-age=3600\r\nContent-type: "
"text/html\r\nConnection: close");
"text/html; charset=utf-8\r\nConnection: close");
else if (endswith(fn, "xml"))
strcpy(ctype, "Cache-Control: no-cache\r\nContent-type: text/xml");
else if (endswith(fn, "json"))
strcpy(ctype, "Cache-Control: no-cache\r\nContent-type: "
"application/json");
"application/json; charset=utf-8");
else if (endswith(fn, "m3u"))
strcpy(ctype,
"Cache-Control: no-cache\r\nContent-type: video/x-mpegurl");
Expand Down

0 comments on commit e6d0be4

Please sign in to comment.