From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Dmitry Gutov Newsgroups: gmane.emacs.bugs Subject: bug#24117: 25.1; url-http-create-request: Multibyte text in HTTP request Date: Tue, 2 Aug 2016 03:52:25 +0300 Message-ID: <7fb3540a-7b74-68cf-2c63-66474de26640@yandex.ru> References: <83d1ltq3p6.fsf@gnu.org> <83popsocg8.fsf@gnu.org> NNTP-Posting-Host: blaine Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-Trace: blaine.gmane.org 1470099204 9411 195.159.176.226 (2 Aug 2016 00:53:24 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 2 Aug 2016 00:53:24 +0000 (UTC) User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:47.0) Gecko/20100101 Thunderbird/47.0 Cc: 24117@debbugs.gnu.org To: Eli Zaretskii , Sho Takemori Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Aug 02 02:53:20 2016 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1bUNxO-00027d-29 for geb-bug-gnu-emacs@m.gmane.org; Tue, 02 Aug 2016 02:53:18 +0200 Original-Received: from localhost ([::1]:53456 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bUNxK-00015I-O8 for geb-bug-gnu-emacs@m.gmane.org; Mon, 01 Aug 2016 20:53:14 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:52027) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bUNxC-00013E-Gz for bug-gnu-emacs@gnu.org; Mon, 01 Aug 2016 20:53:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bUNx8-00088I-7E for bug-gnu-emacs@gnu.org; Mon, 01 Aug 2016 20:53:05 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:55948) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bUNx8-000885-4X for bug-gnu-emacs@gnu.org; Mon, 01 Aug 2016 20:53:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1bUNx7-0007Ry-QP for bug-gnu-emacs@gnu.org; Mon, 01 Aug 2016 20:53:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Dmitry Gutov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 02 Aug 2016 00:53:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 24117 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 24117-submit@debbugs.gnu.org id=B24117.147009915528609 (code B ref 24117); Tue, 02 Aug 2016 00:53:01 +0000 Original-Received: (at 24117) by debbugs.gnu.org; 2 Aug 2016 00:52:35 +0000 Original-Received: from localhost ([127.0.0.1]:53245 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bUNwh-0007RN-In for submit@debbugs.gnu.org; Mon, 01 Aug 2016 20:52:35 -0400 Original-Received: from mail-lf0-f43.google.com ([209.85.215.43]:34844) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bUNwf-0007RA-Ma for 24117@debbugs.gnu.org; Mon, 01 Aug 2016 20:52:34 -0400 Original-Received: by mail-lf0-f43.google.com with SMTP id f93so127167762lfi.2 for <24117@debbugs.gnu.org>; Mon, 01 Aug 2016 17:52:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:subject:to:references:cc:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding; bh=51WBSaetjLRS4H/3dNAwWJIjoULYOhiW1EiN+W8DSFo=; b=mNds6oTM0qH/0mAEQJ57s+iNCOscQKyicDm1U1+H34ppduOOYXASdMxI8o+FHBP9Xn 6wtShSZavPaSQpDNVIdXj0b6a9K9VeCACe49vql2GvECg9kqCfoGPOlFNfz9cTJnQBuA myJxbMcXowiiic/x+6NQ84lkX3MCeVjKGx+2LuamMcf34XltZLM1o2aQFing2VpQs17Z NvWhxzUI+89THgaXvoC26Ui/IVPsRpnKnpJQqidpjwSIBM+tmM6+/ZqiTCJShFjtTMNk Xol5EiZdNM6zOSiXt6OCewm3UqfUnfQ1u1FlcUb46XLPAG3dNWKhGgQlfNk3vj8ApZRT GBJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:subject:to:references:cc:from:message-id :date:user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=51WBSaetjLRS4H/3dNAwWJIjoULYOhiW1EiN+W8DSFo=; b=BNuWjn+JnUY4JxJmcZc5MzIyLwBj7BKB/SVBd0Kbzaz59mjI9nI8P+ZwJ5qGJD+gTj 0pAYrNFNyEh+jltgsRVR/3OHHDLtLyQB/JJXCOUwuXUq7udV9OLDbFMUToZBE+47H1gT Km0TneHBdydyPCkVcsRNFMSt4qj0I1EirUkhldSReNlNT7NmbxC6MJh9boi1LgWlw8Bo +IFVL3mlCUMa70yYlO8xIEZFL+JV1SgNX6erc0C2kLv/xJXnGf/6oisCW+uFNRFxwdUd h85WxIBAaFMQEgR3PESQgzvi4JJctIZczVEdvvTnQ68RDIZyHBNJUIgv0DUxoJd3U2wG zX4g== X-Gm-Message-State: AEkoouuXP/5cp/pU+M0ov6iVdaWRxWU0TOyiFFc0tSrEEqa5oVJgY2mX9CnnIU3n7h+rHg== X-Received: by 10.25.87.2 with SMTP id l2mr21090481lfb.170.1470099147673; Mon, 01 Aug 2016 17:52:27 -0700 (PDT) Original-Received: from [192.168.1.190] ([178.252.127.243]) by smtp.googlemail.com with ESMTPSA id r76sm5615618lfi.35.2016.08.01.17.52.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 01 Aug 2016 17:52:26 -0700 (PDT) In-Reply-To: <83popsocg8.fsf@gnu.org> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:121767 Archived-At: 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?