diff options
author | Chad Loder <cloder@cvs.openbsd.org> | 2003-02-16 15:55:00 +0000 |
---|---|---|
committer | Chad Loder <cloder@cvs.openbsd.org> | 2003-02-16 15:55:00 +0000 |
commit | b8233ad5afc6cba160cb2ebd7aac334097b8c777 (patch) | |
tree | 32ab16b0f3b36b9a5cdfe513c6b192ebdcef416f /usr.sbin | |
parent | 128782b4d5b3ae0ff14762284e3cea2df127b636 (diff) |
My last commit uses base64 for the multipart MIME boundary id. Since
the base64 alphabet includes the characters '/', '+', and '=', it may
violate section 4 of RFC 1341, which says that these kinds of characters
must be quoted in order to be used as a header parameter. Pointed out
by Wouter Clarie (rimshot AT pandora DOT be).
My solution is not to quote the parameter (I'm afraid that will break
simple browsers) but to replace special characters with alphabetic
characters so that the resulting string is entirely alphanumeric. We
don't want to use hex here, the alphabet is too small.
"not too ugly for me" deraadt@, "a bit ugly but good enough" henning@,
"that might be better than quoting" wouter
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/httpd/src/main/http_protocol.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/usr.sbin/httpd/src/main/http_protocol.c b/usr.sbin/httpd/src/main/http_protocol.c index 12793195e1d..1535b1aa0b1 100644 --- a/usr.sbin/httpd/src/main/http_protocol.c +++ b/usr.sbin/httpd/src/main/http_protocol.c @@ -284,7 +284,7 @@ static int byterange_boundary(request_rec *r, long start, long end, int output) API_EXPORT(int) ap_set_byterange(request_rec *r) { const char *range, *if_range, *match; - char *bbuf; + char *bbuf, *b; u_int32_t rbuf[12]; /* 48 bytes yields 64 base64 chars */ long length, start, end, one_start = 0, one_end = 0; size_t u; @@ -338,6 +338,11 @@ API_EXPORT(int) ap_set_byterange(request_rec *r) bbuf = ap_palloc(r->pool, ap_base64encode_len(sizeof(rbuf))); ap_base64encode(bbuf, (const unsigned char *)rbuf, sizeof(rbuf)); + for (b = bbuf; *b != '\0'; b++) { + if (!isalnum(*b)) + *b = 'a'; + } + r->boundary = bbuf; length = 0; |