From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Alain Schneble Newsgroups: gmane.emacs.devel Subject: Re: [PATCH] url: Wrap cookie headers in url-http--encode-string. Date: Fri, 9 Sep 2016 20:02:43 +0200 Message-ID: <86d1kdq7cs.fsf@realize.ch> References: <20160907153014.15752-1-toke@toke.dk> <87inu7k5z4.fsf@toke.dk> <83bmzzaawr.fsf@gnu.org> <877fank1oc.fsf@toke.dk> <87inu6iim8.fsf@toke.dk> <2563921f-d20d-753b-09eb-c8671bc5b6d6@yandex.ru> <87a8fiidso.fsf@toke.dk> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable X-Trace: blaine.gmane.org 1473444244 26389 195.159.176.226 (9 Sep 2016 18:04:04 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Fri, 9 Sep 2016 18:04:04 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (windows-nt) Cc: Eli Zaretskii , emacs-devel@gnu.org, monnier@iro.umontreal.ca, Dmitry Gutov To: Toke =?iso-8859-1?Q?H=F8iland-J=F8rgensen?= Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Sep 09 20:04:00 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 1biQ9Y-0005YS-1u for ged-emacs-devel@m.gmane.org; Fri, 09 Sep 2016 20:03:52 +0200 Original-Received: from localhost ([::1]:59529 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1biQ9W-0003WA-2Q for ged-emacs-devel@m.gmane.org; Fri, 09 Sep 2016 14:03:50 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:54841) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1biQ9L-0003Tz-R2 for emacs-devel@gnu.org; Fri, 09 Sep 2016 14:03:40 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1biQ9J-0004Db-Ls for emacs-devel@gnu.org; Fri, 09 Sep 2016 14:03:38 -0400 Original-Received: from clientmail.realize.ch ([46.140.89.53]:3646) by eggs.gnu.org with smtp (Exim 4.71) (envelope-from ) id 1biQ9D-0004CU-RD; Fri, 09 Sep 2016 14:03:32 -0400 Original-Received: from rintintin.hq.realize.ch.lan.rit ([192.168.0.105]) by clientmail.realize.ch ; Fri, 9 Sep 2016 20:03:18 +0200 Original-Received: from MYNGB (192.168.66.64) by rintintin.hq.realize.ch.lan.rit (192.168.0.105) with Microsoft SMTP Server (TLS) id 15.0.516.32; Fri, 9 Sep 2016 20:02:45 +0200 In-Reply-To: <87a8fiidso.fsf@toke.dk> ("Toke \=\?iso-8859-1\?Q\?H\=F8iland-J\=F8\?\= \=\?iso-8859-1\?Q\?rgensen\=22's\?\= message of "Thu, 08 Sep 2016 17:58:31 +0200") X-ClientProxiedBy: rintintin.hq.realize.ch.lan.rit (192.168.0.105) To rintintin.hq.realize.ch.lan.rit (192.168.0.105) X-detected-operating-system: by eggs.gnu.org: Windows NT kernel [generic] X-Received-From: 46.140.89.53 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:207321 Archived-At: Toke H=F8iland-J=F8rgensen writes: > Dmitry Gutov writes: >> >> Could you post the full recipe? > > (url-retrieve-synchronously "http://google.se") ; sets a cookie > (let* ((url-request-data (encode-coding-string "=E6=F8=E5" 'utf-8))) > (url-retrieve-synchronously "http://google.se")) ; crashes Just two notes on this: 1. This example uses a GET request with some body data. I don't think that this is a real use case. Of course, with other requests such as POST, where some body data is typically sent, we might run into the same issue. 2. The reason why it crashes in this example is not because the cookie contains some non-ascii characters but because the ascii-only cookie-value gets converted into a multibyte string internally. If you save and reload the cookie file after the first `url-retrieve-synchronously' that sets the cookie, the error goes away. So this ... (url-retrieve-synchronously "http://google.se") (url-cookie-write-file) (url-cookie-parse-file) (let* ((url-request-data (encode-coding-string "=E6=F8=E5" 'utf-8))) (url-retrieve-synchronously "http://google.se")) ... works properly. The point is that while accepting and parsing the cookie, the cookie-value gets turned into a multibyte string in `url-parse-args' called from `url-cookie-handle-set-cookie'. Not sure if that should happen if a multibyte string is not really needed... =20=20=20 And while reloading the cookie file, the cookie-value is read back as a non multibyte-string, as I would have expected it to be in the first place. Alain