X-Git-Url: https://gitweb.ps.run/ps-cgit/blobdiff_plain/438bac6f579dab5b8f64e8ce42b88cfc3f053b28..e9cbdf64632fbe64d6b0c4974ac947ef954938e7:/html.c?ds=sidebyside diff --git a/html.c b/html.c index 155cde5..d89df3a 100644 --- a/html.c +++ b/html.c @@ -8,12 +8,6 @@ #include "cgit.h" #include "html.h" -#include -#include -#include -#include -#include -#include /* Percent-encoding of each character, except: a-zA-Z0-9!$()*,./:;@- */ static const char* url_escape_table[256] = { @@ -127,13 +121,6 @@ void html_vtxtf(const char *format, va_list ap) strbuf_release(&buf); } -void html_status(int code, const char *msg, int more_headers) -{ - htmlf("Status: %d %s\n", code, msg); - if (!more_headers) - html("\n"); -} - void html_txt(const char *txt) { const char *t = txt; @@ -252,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("