From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#23750: 25.0.95; bug in url-retrieve or json.el Date: Mon, 20 Jun 2016 17:39:04 +0300 Message-ID: <837fdj9b7b.fsf@gnu.org> References: <358304f6-98e1-fa10-8805-aa9b73db406a@yandex.ru> <83k2hl828z.fsf@gnu.org> Reply-To: Eli Zaretskii NNTP-Posting-Host: plane.gmane.org X-Trace: ger.gmane.org 1466434536 16009 80.91.229.3 (20 Jun 2016 14:55:36 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 20 Jun 2016 14:55:36 +0000 (UTC) Cc: 23750@debbugs.gnu.org To: Leo Liu Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Jun 20 16:55:25 2016 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1bF0bk-00034e-Cu for geb-bug-gnu-emacs@m.gmane.org; Mon, 20 Jun 2016 16:55:24 +0200 Original-Received: from localhost ([::1]:44137 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bF0bg-000350-Ey for geb-bug-gnu-emacs@m.gmane.org; Mon, 20 Jun 2016 10:55:20 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:56849) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bF0Nt-0003pZ-Ky for bug-gnu-emacs@gnu.org; Mon, 20 Jun 2016 10:41:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bF0Np-0005bE-TE for bug-gnu-emacs@gnu.org; Mon, 20 Jun 2016 10:41:04 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:35489) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bF0Np-0005bA-QB for bug-gnu-emacs@gnu.org; Mon, 20 Jun 2016 10:41:01 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1bF0Np-0006Oj-Lk for bug-gnu-emacs@gnu.org; Mon, 20 Jun 2016 10:41:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 20 Jun 2016 14:41:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 23750 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 23750-submit@debbugs.gnu.org id=B23750.146643360724525 (code B ref 23750); Mon, 20 Jun 2016 14:41:01 +0000 Original-Received: (at 23750) by debbugs.gnu.org; 20 Jun 2016 14:40:07 +0000 Original-Received: from localhost ([127.0.0.1]:47826 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bF0Mx-0006NU-85 for submit@debbugs.gnu.org; Mon, 20 Jun 2016 10:40:07 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:37202) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bF0Mw-0006Mq-7s for 23750@debbugs.gnu.org; Mon, 20 Jun 2016 10:40:06 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bF0Mo-0005Dx-IW for 23750@debbugs.gnu.org; Mon, 20 Jun 2016 10:40:01 -0400 Original-Received: from fencepost.gnu.org ([2001:4830:134:3::e]:47518) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bF0Mo-0005DO-F2; Mon, 20 Jun 2016 10:39:58 -0400 Original-Received: from 84.94.185.246.cable.012.net.il ([84.94.185.246]:3426 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_128_CBC_SHA1:128) (Exim 4.82) (envelope-from ) id 1bF0Mm-0007lP-MD; Mon, 20 Jun 2016 10:39:57 -0400 In-reply-to: (message from Leo Liu on Mon, 20 Jun 2016 08:15:26 +0800) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] 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:119835 Archived-At: > From: Leo Liu > Date: Mon, 20 Jun 2016 08:15:26 +0800 > > > This particular bug came from this: > > > > "Content-length: " (number-to-string (length url-http-data)) > > > > Which gives wrong value when url-http-data is multibyte (it should be > > length in bytes). So then, the HTTP server on the other side saw the > > wrong body length and truncated the body when reading the request. > > As Dmitry mentioned earlier json-encode in 25.1 produces multibyte > strings and makes it easier to hit this bug when consuming JSON API's. > There are three parties that are suspicious: 1) JSON API server 2) > JSON.el 3) URL. It took me a while to realise it's URL's fault IOW the > bug isn't easy to debug. This is somewhat related to changes brought in > by 25.1. I understand that url-http expects unibyte strings. So my suggestion is to test that, and signal an error if the requirement is violated, with an error message text that could be understood by users and developers. Alternatively, we could encode multibyte strings in UTF-8, if we want to attempt to silently cope with such strings. In any case, using string-*-unibyte functions for that is not needed, and I'm quite sure their use in this case is a left-over from an era long gone.