Fix malformed HTTP output of JSON fields

This commit is contained in:
Andrew Bettison 2015-08-31 19:11:39 +09:30
parent 714ea63190
commit 0e783c6b73

View File

@ -1960,16 +1960,17 @@ static strbuf strbuf_status_body(strbuf sb, struct http_response *hr, const char
else {
hr->header.content_type = CONTENT_TYPE_HTML;
strbuf_sprintf(sb, "<html>\n<h1>%03u %s</h1>", hr->result_code, message);
strbuf_puts(sb, "\n<dl>");
unsigned i;
for (i = 0; i < NELS(hr->result_extra); ++i)
if (hr->result_extra[i].label) {
strbuf_puts(sb, "\n<dl><dt>");
strbuf_puts(sb, "\n<dt>");
strbuf_html_escape(sb, hr->result_extra[i].label, strlen(hr->result_extra[i].label));
strbuf_puts(sb, "</dt><dd>");
strbuf_json_atom_as_html(sb, &hr->result_extra[i].value);
strbuf_puts(sb, "</dd></dl>");
strbuf_puts(sb, "</dd>");
}
strbuf_puts(sb, "\n</html>");
strbuf_puts(sb, "\n</dl>\n</html>");
}
return sb;
}