diff options
authorBryce Kwon <bryce@brycekwon.com>
committerBryce Kwon <bryce@brycekwon.com>
commit
parent
tree
download
Keep every control byte out of a header value
A quoted header value escaped only the quote, the backslash, CR and LF. A web server refuses a response whose header holds any other control byte, so a file named with one could not be downloaded at all.
Diffstat (limited to 'source/html.c')
-rw-r--r--source/html.c4
1 file changed, 4 insertions, 0 deletions
diff --git a/source/html.c b/source/html.c
index b6e62a6..d1e28f8 100644
--- a/source/html.c
+++ b/source/html.c
@@ -367,6 +367,10 @@ void html_header_arg_in_quotes(const char *txt)
esc = "\\n";
else if (c == '"')
esc = "\\\"";
+ // A header line carries no other control byte either, and a web
+ // server refuses the whole response over one.
+ else if (c < 0x20 || c == 0x7f)
+ esc = "?";
if (esc) {
html_raw(txt, p - txt);
html(esc);