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 05:40:17 +0300 Message-ID: <83h9co8twu.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 1466390554 13347 80.91.229.3 (20 Jun 2016 02:42:34 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 20 Jun 2016 02:42:34 +0000 (UTC) Cc: 23750@debbugs.gnu.org, monnier@IRO.UMontreal.CA, sdl.web@gmail.com To: Dmitry Gutov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Jun 20 04:42:23 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 1bEpAM-00063s-Ei for geb-bug-gnu-emacs@m.gmane.org; Mon, 20 Jun 2016 04:42:22 +0200 Original-Received: from localhost ([::1]:40892 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bEpAI-0005Fh-AZ for geb-bug-gnu-emacs@m.gmane.org; Sun, 19 Jun 2016 22:42:18 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:59533) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bEpA8-0005EO-QO for bug-gnu-emacs@gnu.org; Sun, 19 Jun 2016 22:42:13 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bEpA3-0000Wi-Fk for bug-gnu-emacs@gnu.org; Sun, 19 Jun 2016 22:42:07 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:34523) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bEpA3-0000Vx-Br for bug-gnu-emacs@gnu.org; Sun, 19 Jun 2016 22:42:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1bEpA2-0004he-Dk for bug-gnu-emacs@gnu.org; Sun, 19 Jun 2016 22:42:02 -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 02:42:02 +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.146639047918027 (code B ref 23750); Mon, 20 Jun 2016 02:42:02 +0000 Original-Received: (at 23750) by debbugs.gnu.org; 20 Jun 2016 02:41:19 +0000 Original-Received: from localhost ([127.0.0.1]:46859 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bEp9L-0004gg-7B for submit@debbugs.gnu.org; Sun, 19 Jun 2016 22:41:19 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:40271) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bEp9J-0004gU-E0 for 23750@debbugs.gnu.org; Sun, 19 Jun 2016 22:41:17 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bEp9D-0000I6-3A for 23750@debbugs.gnu.org; Sun, 19 Jun 2016 22:41:12 -0400 Original-Received: from fencepost.gnu.org ([2001:4830:134:3::e]:36794) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bEp97-0000GI-Rr; Sun, 19 Jun 2016 22:41:05 -0400 Original-Received: from 84.94.185.246.cable.012.net.il ([84.94.185.246]:3072 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_128_CBC_SHA1:128) (Exim 4.82) (envelope-from ) id 1bEp95-00009n-Qv; Sun, 19 Jun 2016 22:41:04 -0400 In-reply-to: (message from Dmitry Gutov on Sun, 19 Jun 2016 21:36:25 +0300) 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:119809 Archived-At: > Cc: 23750@debbugs.gnu.org, monnier@IRO.UMontreal.CA, sdl.web@gmail.com > From: Dmitry Gutov > Date: Sun, 19 Jun 2016 21:36:25 +0300 > > 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. Or > something along these lines. So this is not a bug in Emacs, but a diagnostic facility to let bugs in applications be discovered? > > IME, neither string-to-unibyte not > > string-as-unibyte should ever be used in applications, their use is > > more often than not a sign of some basic misunderstanding of text > > encoding. For starters, how come 8-bit bytes wind up in that > > function, and what do they stand for? > > Some 8-byte encoding of the HTTP request body. > > Anyway, yes, the hope is that the programmer uses something like > encode-coding-string to produce that value (and picks the encoding, and > indicates it in the appropriate HTTP header). Then string-to-unibyte > will simply be a no-op. But we need to catch the case when they don't, > and this seems to be the easiest way to do this. If this is what you need, why not simply test the payload for being a unibyte string? There a function, multibyte-string-p, for that.