[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#24117: 25.1; url-http-create-request: Multibyte text in HTTP request

From: Dmitry Gutov
Subject: bug#24117: 25.1; url-http-create-request: Multibyte text in HTTP request
Date: Tue, 2 Aug 2016 03:52:25 +0300
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:47.0) Gecko/20100101 Thunderbird/47.0

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


(multibyte-string-p (url-host (url-generic-parse-url "";)))

=> 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?

reply via email to

[Prev in Thread] Current Thread [Next in Thread]