Subject: Re: bug#31248: 27.0.50; Regression: Multibyte text in HTTP request

From: Lars Ingebrigtsen <[email-masked]>
Date: Tue, 24 Apr 2018 14:17:38 +0200

Aaron Jensen <[email-masked]> writes:

> On Tue, Apr 24, 2018 at 5:06 AM, Lars Ingebrigtsen <[email-masked]> wrote:
>> And this made the entire request string multibyte.
>
> Hm, that's odd. What does that have to do with the url-request-data w/
> the emoji?

That's the *really* obscure bit.  :-)

> If I change that to just an "x" then it won't fail in the
> same way:
>
> (let ((url "http://requestbin.fullcontact.com/1kkmrpx1")
>       (url-request-method "POST")
>       (url-request-data (encode-coding-string "x" 'utf-8))
>       (url-request-extra-headers '(("Content-Type" . "application/json")))
>       (url-http-proxy nil))
>   (url-retrieve url (lambda (_))))

So you start with a thing that's now multibyte:

(url-host u)
=> "requestbin.fullcontact.com"

(multibyte-string-p (url-host u))
=> t

(setq data (encode-coding-string "📦" 'utf-8))
(multibyte-string-p data)
=> nil

Then concatenate:

(setq foo (concat (url-host u) data))
"\360\237\223\246"
foo
=> "requestbin.fullcontact.com\360\237\223\246"
(multibyte-string-p foo)
=> t
(string-bytes data)
=> 4

(length foo)
=> 30
(string-bytes foo)
=> 34

Fun!  :-)

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no