GNU bug report logs -
#24117
25.1; url-http-create-request: Multibyte text in HTTP request
Previous Next
Reported by: Sho Takemori <stakemorii <at> gmail.com>
Date: Sun, 31 Jul 2016 08:28:02 UTC
Severity: normal
Found in version 25.1
Done: Dmitry Gutov <dgutov <at> yandex.ru>
Bug is archived. No further changes may be made.
Full log
Message #17 received at 24117 <at> debbugs.gnu.org (full text, mbox):
On 08/01/2016 04:17 PM, Eli Zaretskii wrote:
> To summarize, I still don't understand how come the error happened.
> Could you perhaps step with Edebug into url-http-create-request, and
> see what is going on there? Or come up with a reproducible recipe of
> calling url-http-create-request that I could examine on my machine?
Here's the essence of the problem:
(length (concat (encode-coding-string "фыва" 'utf-8)
(string-as-multibyte "abc")))
=> 11
(string-bytes (concat (encode-coding-string "фыва" 'utf-8)
(string-as-multibyte "abc")))
=> 19
And
(multibyte-string-p (url-host (url-generic-parse-url "http://127.0.0.1")))
=> t
Apparently, url-generic-parse-url creates a multibyte string for the
host name because it performs its parsing in a buffer. And
url-http-create-request uses the return value of (url-host
url-http-target-url) to set the Location header. And all of that gets
concatenated in the request.
Some possible solutions:
- Perform the "string-bytes = length" verification only for
url-http-data, not the the whole request string. This strikes me as
ugly, but apparently we've been living with using a multibyte string
here for a while.
- Call url-encode-url on the return value of (url-host
url-http-target-url), and hope that no similar problem pops up with any
of the related variables. This does solve the immediate problem with
anaconda-mode, I've checked.
- Something else?
This bug report was last modified 8 years and 12 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.