Diff options
| author | Bryce Kwon <bryce@brycekwon.com> | |
|---|---|---|
| committer | Bryce Kwon <bryce@brycekwon.com> | |
| commit | ||
| parent | ||
| tree | ||
| download | ||
Add filename* for a download name past ASCII
The plain, snapshot and blob pages sent a name such as café.txt raw in
filename, which a client may read as ISO-8859-1. RFC 6266 has such a
name sent again as filename*, percent-encoded in UTF-8, for a client
that knows the form, with filename first for one that does not. The
extended form carries UTF-8 alone, so a name that is not valid UTF-8
keeps the plain filename by itself.
Diffstat (limited to 'source/html.c')
| -rw-r--r-- | source/html.c | 20 |
1 file changed, 20 insertions, 0 deletions
diff --git a/source/html.c b/source/html.c index ce9344d..00eb7c6 100644 --- a/source/html.c +++ b/source/html.c @@ -471,6 +471,26 @@ void html_header_arg_in_quotes(const char *txt) html(txt); } +void html_header_ext_value(const char *txt) +{ + const char *p = txt; + + while (p && *p) { + unsigned char c = *p; + + // The attr-char set of RFC 8187, which leaves nothing that + // could end the parameter or the header line. + if (!isalnum(c) && !strchr("!#$&+-.^_`|~", c)) { + html_raw(txt, p - txt); + htmlf("%%%02X", c); + txt = p + 1; + } + p++; + } + if (p != 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 |
