ui-shared: prevent malicious filename from injecting headers

This commit is contained in:
Jason A. Donenfeld
2016-01-14 14:28:37 +01:00
والد 4291453ec3
کامیت 513b3863d9
3فایلهای تغییر یافته به همراه32 افزوده شده و 3 حذف شده

26
html.c
مشاهده پرونده

@ -239,6 +239,32 @@ void html_url_arg(const char *txt)
html(txt);
}
void html_header_arg_in_quotes(const char *txt)
{
const char *t = txt;
while (t && *t) {
unsigned char c = *t;
const char *e = NULL;
if (c == '\\')
e = "\\\\";
else if (c == '\r')
e = "\\r";
else if (c == '\n')
e = "\\n";
else if (c == '"')
e = "\\\"";
if (e) {
html_raw(txt, t - txt);
html(e);
txt = t + 1;
}
t++;
}
if (t != txt)
html(txt);
}
void html_hidden(const char *name, const char *value)
{
html("<input type='hidden' name='");