From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: =?utf-8?Q?Toke_H=C3=B8iland-J=C3=B8rgensen?= Newsgroups: gmane.emacs.devel Subject: Re: [PATCH] url: Wrap cookie headers in url-http--encode-string. Date: Wed, 07 Sep 2016 20:25:07 +0200 Message-ID: <877fank1oc.fsf@toke.dk> References: <20160907153014.15752-1-toke@toke.dk> <87inu7k5z4.fsf@toke.dk> <83bmzzaawr.fsf@gnu.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: blaine.gmane.org 1473272738 20799 195.159.176.226 (7 Sep 2016 18:25:38 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 7 Sep 2016 18:25:38 +0000 (UTC) Cc: monnier@iro.umontreal.ca, emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Sep 07 20:25:33 2016 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bhhXM-0004TX-S6 for ged-emacs-devel@m.gmane.org; Wed, 07 Sep 2016 20:25:28 +0200 Original-Received: from localhost ([::1]:42390 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bhhXK-0006CN-Oh for ged-emacs-devel@m.gmane.org; Wed, 07 Sep 2016 14:25:26 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:32774) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bhhXB-0006Aq-Li for emacs-devel@gnu.org; Wed, 07 Sep 2016 14:25:18 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bhhXA-0007gP-MH for emacs-devel@gnu.org; Wed, 07 Sep 2016 14:25:17 -0400 Original-Received: from mail2.tohojo.dk ([77.235.48.147]:45852) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bhhX5-0007do-Pq; Wed, 07 Sep 2016 14:25:12 -0400 X-Virus-Scanned: amavisd-new at mail2.tohojo.dk DKIM-Filter: OpenDKIM Filter v2.10.3 mail2.tohojo.dk 1607440D5E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=toke.dk; s=201310; t=1473272708; bh=d9n95OfBuCTaZC4Kf0dqg/KVRdStgtEBwINCny9wCus=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=QVWvfO9ruepUNCnPPoG3LWT4JTYDvpEaUtiibXQhmI/uD0Y4d7IY9CQEfCsiDpNDL PfiO7LXGez4XwBVmD6NTY7SGfVMPjHAqUeIOJ01E5tJxyOJE9231w+RhidWQ2mi6sc iCceDNJwQ+1cB/AnlAGy/fBeOvVHpupmIHcBAVKo= Original-Received: by alrua-kau.kau.toke.dk (Postfix, from userid 1000) id 584E3C4027D; Wed, 7 Sep 2016 20:25:07 +0200 (CEST) In-Reply-To: <83bmzzaawr.fsf@gnu.org> (Eli Zaretskii's message of "Wed, 07 Sep 2016 20:15:48 +0300") X-Clacks-Overhead: GNU Terry Pratchett X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 77.235.48.147 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:207269 Archived-At: Eli Zaretskii writes: >> From: Toke H=C3=B8iland-J=C3=B8rgensen >> Date: Wed, 07 Sep 2016 18:52:15 +0200 >> Cc: emacs-devel@gnu.org >>=20 >> Right, well, I'm not actually sure that there's any multibyte *content* >> in the cookie header. But somehow, without this patch, if there's an >> UTF-8 payload, (string-bytes request) returns an extra byte for each >> UTF-8 octet. I have no idea why that is; basically, what I would see was: >>=20 >> (string-bytes url-http-data) =3D=3D (length url-http-data) >>=20 >> but >>=20 >> (string-bytes (substring request (* -1 (length (url-http-data))))) being >> two bytes longer (for a single UTF-8 character in the payload). > > Can you show a test case where this happens? Appears to be any request with an UTF-8 encoded payload that goes to a host that has cookies stored. This snippet triggers the error for me if I replace example.org with a domain that has cookies stored in ~/.emacs.d/url/cookies: (let* ((url-request-data (encode-coding-string "=C3=A6=C3=B8=C3=A5" 'utf-8)= )) (url-retrieve-synchronously "http://example.org")) -Toke