From mboxrd@z Thu Jan  1 00:00:00 1970
Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail
From: dick <dick.r.chiang@gmail.com>
Newsgroups: gmane.emacs.bugs
Subject: bug#39506: patch
Date: Fri, 07 Feb 2020 19:40:34 -0500
Message-ID: <87tv419ail.fsf@dick>
Mime-Version: 1.0
Content-Type: text/x-diff; charset=utf-8
Content-Transfer-Encoding: quoted-printable
Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202";
	logging-data="110246"; mail-complaints-to="usenet@ciao.gmane.io"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux)
To: 39506@debbugs.gnu.org
Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Feb 08 01:41:14 2020
Return-path: <bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org>
Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org
Original-Received: from lists.gnu.org ([209.51.188.17])
	by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
	(Exim 4.92)
	(envelope-from <bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org>)
	id 1j0EBM-000Sb8-Rm
	for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 08 Feb 2020 01:41:12 +0100
Original-Received: from localhost ([::1]:36684 helo=lists1p.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.90_1)
	(envelope-from <bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org>)
	id 1j0EBL-0000aZ-TH
	for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 07 Feb 2020 19:41:11 -0500
Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:44157)
 by lists.gnu.org with esmtp (Exim 4.90_1)
 (envelope-from <Debian-debbugs@debbugs.gnu.org>) id 1j0EBE-0000X8-0k
 for bug-gnu-emacs@gnu.org; Fri, 07 Feb 2020 19:41:05 -0500
Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <Debian-debbugs@debbugs.gnu.org>) id 1j0EBC-0004vF-Ow
 for bug-gnu-emacs@gnu.org; Fri, 07 Feb 2020 19:41:03 -0500
Original-Received: from debbugs.gnu.org ([209.51.188.43]:44521)
 by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16)
 (Exim 4.71) (envelope-from <Debian-debbugs@debbugs.gnu.org>)
 id 1j0EBC-0004ui-K8
 for bug-gnu-emacs@gnu.org; Fri, 07 Feb 2020 19:41:02 -0500
Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2)
 (envelope-from <Debian-debbugs@debbugs.gnu.org>) id 1j0EBC-0007Py-Iy
 for bug-gnu-emacs@gnu.org; Fri, 07 Feb 2020 19:41:02 -0500
X-Loop: help-debbugs@gnu.org
Resent-From: dick <dick.r.chiang@gmail.com>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces@debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@gnu.org
Resent-Date: Sat, 08 Feb 2020 00:41:02 +0000
Resent-Message-ID: <handler.39506.B.158112244328479@debbugs.gnu.org>
Resent-Sender: help-debbugs@gnu.org
X-GNU-PR-Message: report 39506
X-GNU-PR-Package: emacs
X-Debbugs-Original-To: bug-gnu-emacs <bug-gnu-emacs@gnu.org>
Original-Received: via spool by submit@debbugs.gnu.org id=B.158112244328479
 (code B ref -1); Sat, 08 Feb 2020 00:41:02 +0000
Original-Received: (at submit) by debbugs.gnu.org; 8 Feb 2020 00:40:43 +0000
Original-Received: from localhost ([127.0.0.1]:50494 helo=debbugs.gnu.org)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <debbugs-submit-bounces@debbugs.gnu.org>)
 id 1j0EAs-0007PH-Pn
 for submit@debbugs.gnu.org; Fri, 07 Feb 2020 19:40:43 -0500
Original-Received: from lists.gnu.org ([209.51.188.17]:43035)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <dick.r.chiang@gmail.com>) id 1j0EAq-0007P9-Ew
 for submit@debbugs.gnu.org; Fri, 07 Feb 2020 19:40:40 -0500
Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:44112)
 by lists.gnu.org with esmtp (Exim 4.90_1)
 (envelope-from <dick.r.chiang@gmail.com>) id 1j0EAp-0008MB-1z
 for bug-gnu-emacs@gnu.org; Fri, 07 Feb 2020 19:40:40 -0500
Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <dick.r.chiang@gmail.com>) id 1j0EAn-0003XI-Gi
 for bug-gnu-emacs@gnu.org; Fri, 07 Feb 2020 19:40:38 -0500
Original-Received: from mail-qt1-x833.google.com ([2607:f8b0:4864:20::833]:36128)
 by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16)
 (Exim 4.71) (envelope-from <dick.r.chiang@gmail.com>)
 id 1j0EAn-0003ON-8y
 for bug-gnu-emacs@gnu.org; Fri, 07 Feb 2020 19:40:37 -0500
Original-Received: by mail-qt1-x833.google.com with SMTP id t13so838106qto.3
 for <bug-gnu-emacs@gnu.org>; Fri, 07 Feb 2020 16:40:36 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; 
 h=from:to:subject:date:message-id:user-agent:mime-version
 :content-disposition:content-transfer-encoding:content-description;
 bh=xS/EMWITDmLJFAUheVzQJaqzLvaOQmEGFNNvTCrFuZI=;
 b=PrM4aD5oEGmkwuG/4+smH9Ene65Sdheo7p+58qJ6bJ4VBOd7HRgCJaVHDAsK3XGTx4
 7PcKgk7ots10M6IKijhhrJsw0YlDjYEJuO0wTLhL/ZjAUwaOAXmGpwkQ0XMUctSUn2sO
 2kVh/gaTYK/JoxdhuwDeDLlae6rNgzeL1bClaiouQVYLlYVhfLNoZiY3Eh4lUrvHJy6i
 XdKK74VCen3zwb5+b/IZM6QHgyJvYkkN8dEALJb489nEaYn1cIt+K3NPDOM9/c5UvYXL
 f3PRXiymIWhBdbgO3Ry/MxNSJZblPXfbNABh8FEtmnFYe6CLBZJqxXEVKgEyntMLOr1c
 7pzg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20161025;
 h=x-gm-message-state:from:to:subject:date:message-id:user-agent
 :mime-version:content-disposition:content-transfer-encoding
 :content-description;
 bh=xS/EMWITDmLJFAUheVzQJaqzLvaOQmEGFNNvTCrFuZI=;
 b=W/jbpOresZ+ATxYJP+U3XSApFBq+6fl+W+i+Ey7lKi1eIe+dbNdY/DENZGrixsXgzB
 P/wS2rDAdsVCHo8GKbmyOg2uWkvF07dydTLtKgVEC1x9f/u4/uEN4z3rsvcuUQ16jzrK
 17CHmX93SDtwBppek4IBYBr2lVkNNouc3SrYTKOSzIPfH5UQEGmY9yCwfz1xY/OYWYpl
 Jna2AC3Du221oEouOvCY83jMhxo/O2/M4w5KIR2vsjEaN/CGSZeUBmAjqh4Xj8LYHXOH
 qxnqVKyCA/0y2W1vEdWepiTfHTVnBJkP0siDM/7D1/y3CFhYHb3lFGbogWmelD9536Dh
 1Jeg==
X-Gm-Message-State: APjAAAXYogABFm5XhLTjfgALIjBUpugi+y+0bLWZ+eFea3A4AFSJUgHW
 XyLxild2+VtBu5wSypaPNlQRIG3X
X-Google-Smtp-Source: APXvYqxIc2vlpu7ofHfuGSMJTsShlfyUfuO51HflYfCXrziHfDuwemzXr7b4FOqOPzeOTO/z1xefmQ==
X-Received: by 2002:ac8:745a:: with SMTP id h26mr915951qtr.320.1581122435658; 
 Fri, 07 Feb 2020 16:40:35 -0800 (PST)
Original-Received: from localhost (pool-100-33-98-8.nycmny.fios.verizon.net.
 [100.33.98.8])
 by smtp.gmail.com with ESMTPSA id 135sm2193779qkl.68.2020.02.07.16.40.34
 for <bug-gnu-emacs@gnu.org>
 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
 Fri, 07 Feb 2020 16:40:34 -0800 (PST)
Content-Disposition: inline;
 filename=0001-Question-assumption-that-mm-source-buffer-is-unibyte.patch
Content-Description: patch
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
 recognized.
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: 209.51.188.43
X-BeenThere: bug-gnu-emacs@gnu.org
List-Id: "Bug reports for GNU Emacs,
 the Swiss army knife of text editors" <bug-gnu-emacs.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/bug-gnu-emacs>,
 <mailto:bug-gnu-emacs-request@gnu.org?subject=unsubscribe>
List-Archive: <https://lists.gnu.org/archive/html/bug-gnu-emacs>
List-Post: <mailto:bug-gnu-emacs@gnu.org>
List-Help: <mailto:bug-gnu-emacs-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/bug-gnu-emacs>,
 <mailto:bug-gnu-emacs-request@gnu.org?subject=subscribe>
Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org
Original-Sender: "bug-gnu-emacs"
 <bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org>
Xref: news.gmane.io gmane.emacs.bugs:175766
Archived-At: <http://permalink.gmane.org/gmane.emacs.bugs/175766>

>From 2674b6a08a90b9a97d3adf2b3e4497b61880e173 Mon Sep 17 00:00:00 2001
From: dickmao <none>
Date: Fri, 7 Feb 2020 19:33:13 -0500
Subject: [PATCH] Question assumption that mm source buffer is unibyte

In my Gnus experience, the source buffer that mm-shr acts upon can be
multibyte.

* lisp/gnus/mm-decode.el (mm-with-part): propagate multibyte/unibyte setting
from source buffer to target.
* test/lisp/gnus/mm-decode-tests.el (test-mm-decode-multibyte): add test
---
 lisp/gnus/mm-decode.el            |  8 ++-----
 test/lisp/gnus/mm-decode-tests.el | 39 +++++++++++++++++++++++++++++++
 2 files changed, 41 insertions(+), 6 deletions(-)
 create mode 100644 test/lisp/gnus/mm-decode-tests.el

diff --git a/lisp/gnus/mm-decode.el b/lisp/gnus/mm-decode.el
index d33bb56dc9..19a18b4f45 100644
--- a/lisp/gnus/mm-decode.el
+++ b/lisp/gnus/mm-decode.el
@@ -1255,16 +1255,12 @@ mm-handle-displayed-p
=20
 (defmacro mm-with-part (handle &rest forms)
   "Run FORMS in the temp buffer containing the contents of HANDLE."
-  ;; The handle-buffer's content is a sequence of bytes, not a sequence of
-  ;; chars, so the buffer should be unibyte.  It may happen that the
-  ;; handle-buffer is multibyte for some reason, in which case now is a go=
od
-  ;; time to adjust it, since we know at this point that it should
-  ;; be unibyte.
   `(let* ((handle ,handle))
      (when (and (mm-handle-buffer handle)
 		(buffer-name (mm-handle-buffer handle)))
        (with-temp-buffer
-	 (mm-disable-multibyte)
+         (set-buffer-multibyte (buffer-local-value 'enable-multibyte-chara=
cters
+                                                   (mm-handle-buffer handl=
e)))
 	 (insert-buffer-substring (mm-handle-buffer handle))
 	 (mm-decode-content-transfer-encoding
 	  (mm-handle-encoding handle)
diff --git a/test/lisp/gnus/mm-decode-tests.el b/test/lisp/gnus/mm-decode-t=
ests.el
new file mode 100644
index 0000000000..8a9d471b74
--- /dev/null
+++ b/test/lisp/gnus/mm-decode-tests.el
@@ -0,0 +1,39 @@
+;;; mm-decode-tests.el --- tests for gnus/mm-decode.el    -*- lexical-bind=
ing:t -*-
+
+;; Copyright (C) 2019-2020 Free Software Foundation, Inc.
+
+;; This file is part of GNU Emacs.
+
+;; GNU Emacs is free software: you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; GNU Emacs is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs.  If not, see <https://www.gnu.org/licenses/>.
+
+;;; Code:
+
+(require 'ert)
+(require 'mm-decode)
+
+(ert-deftest test-mm-decode-multibyte ()
+  (should
+   (or (not (fboundp 'libxml-parse-html-region))
+       (with-temp-buffer
+         (set-buffer-multibyte t)
+         (save-excursion
+           (insert "<p>=E6=9C=80=E8=BF=91=E4=B9=9F=E6=83=B3=E5=B0=9D=E8=AF=
=95,=E4=BD=86=E6=98=AF=E6=84=9F=E8=A7=89=E8=9B=AE=E9=9A=BE=E7=9A=84,=E6=AF=
=94=E5=A6=82=E4=B8=8D=E7=9F=A5=E9=81=93=E5=A6=82=E4=BD=95=E5=9C=A8"))
+         (let ((handle (mm-make-handle
+                        (current-buffer)
+                        (rfc2231-parse-qp-string
+                         "Content-Type: text/html; charset=3DUTF-8"))))
+           (not (zerop (length (with-temp-buffer (mm-shr handle)
+                                                 (buffer-string))))))))))
+
+;;; mm-decode-tests.el ends here
--=20
2.24.1