diff options
| author | Bryce Kwon <bryce@brycekwon.com> | |
|---|---|---|
| committer | Bryce Kwon <bryce@brycekwon.com> | |
| commit | ||
| parent | ||
| tree | ||
| download | ||
Keep the query string across the about redirects
The hop to the trailing-slash form of the about page, and the hop back
to the summary of a repository without a readme, were built from the
path alone, so a request for the about page of another branch landed
on the default one. The query goes into the Location line as the
client sent it, with any byte a header cannot carry percent-encoded.
Diffstat (limited to 'source/html.c')
| -rw-r--r-- | source/html.c | 22 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
1 file changed, 22 insertions, 0 deletions
diff --git a/source/html.c b/source/html.c index a1d244b..96b1b52 100644 --- a/source/html.c +++ b/source/html.c @@ -339,6 +339,28 @@ void html_header_arg_in_quotes(const char *txt) html(txt); } +/* + * A query string goes into a header the way it arrived, already encoded by + * the client, except that a byte a header line cannot carry is percent-encoded + * so the line stays one line. + */ +void html_header_query(const char *txt) +{ + const char *p = txt; + + while (p && *p) { + unsigned char c = *p; + if (c <= ' ' || c >= 0x7f) { + html_raw(txt, p - txt); + html(url_escape_table[c]); + txt = p + 1; + } + p++; + } + if (p != txt) + html(txt); +} + void html_hidden(const char *name, const char *value) { html("<input type='hidden' name='"); |
