GNU bug report logs - #43441
27.1; [PATCH] Fix incorrectly base64-padded faces in gnus-convert-face-to-png

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: emacs; Reported by: Alex Bochannek <alex@HIDDEN>; Keywords: patch; dated Wed, 16 Sep 2020 06:08:02 UTC; Maintainer for emacs is bug-gnu-emacs@HIDDEN.

Message received at 43441 <at> debbugs.gnu.org:


Received: (at 43441) by debbugs.gnu.org; 17 Sep 2020 15:31:28 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Sep 17 11:31:28 2020
Received: from localhost ([127.0.0.1]:38679 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1kIvsd-0007dC-90
	for submit <at> debbugs.gnu.org; Thu, 17 Sep 2020 11:31:27 -0400
Received: from quimby.gnus.org ([95.216.78.240]:42190)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <larsi@HIDDEN>) id 1kIvsa-0007Ve-EL
 for 43441 <at> debbugs.gnu.org; Thu, 17 Sep 2020 11:31:26 -0400
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org;
 s=20200322; h=Content-Type:MIME-Version:Message-ID:In-Reply-To:Date:
 References:Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding:
 Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender:
 Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:
 List-Subscribe:List-Post:List-Owner:List-Archive;
 bh=qZ3rwku652w7fuWX7vuG3ktu8bBIfd12O34cGEXijes=; b=DbAy5bvrrcbeOk1hQqBx/bbogr
 yIlgfYLJQCGxCEr0tDK1+CSeRC8Fg539WrD/XaCbMvYWJkHUSkmUYrspEFzcA+sXj4Fym1S2l3/wS
 6qhaY+Cbj0ZYmFuAhdtOPGTgNVpR0UDe1JSl7xqQkl7IyaSzzKhMuWyUIh22J226BPV8=;
Received: from cm-84.212.202.86.getinternet.no ([84.212.202.86] helo=xo)
 by quimby with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.92) (envelope-from <larsi@HIDDEN>)
 id 1kIvsR-0001wR-0W; Thu, 17 Sep 2020 17:31:17 +0200
From: Lars Ingebrigtsen <larsi@HIDDEN>
To: Alex Bochannek <alex@HIDDEN>
Subject: Re: bug#43441: 27.1; [PATCH] Fix incorrectly base64-padded faces in
 gnus-convert-face-to-png
References: <m2ft7i9rwi.fsf@HIDDEN>
X-Now-Playing: PJ Harvey's _Dry Demos_: "Plants And Rags"
Date: Thu, 17 Sep 2020 17:31:13 +0200
In-Reply-To: <m2ft7i9rwi.fsf@HIDDEN> (Alex Bochannek's message of "Tue, 
 15 Sep 2020 23:06:53 -0700")
Message-ID: <875z8cpghq.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Report: Spam detection software, running on the system "quimby.gnus.org",
 has NOT identified this incoming email as spam.  The original
 message has been attached to this so you can view it or label
 similar future email.  If you have any questions, see
 @@CONTACT_ADDRESS@@ for details.
 Content preview: Alex Bochannek <alex@HIDDEN> writes: > I don't suspect
 this problem is widespread in other uses of the base64 > decoder, so it seems
 appropriate to me to just patch > gnus-convert-face-to-png to generate the
 right amount of padding. 
 Content analysis details:   (-2.9 points, 5.0 required)
 pts rule name              description
 ---- ---------------------- --------------------------------------------------
 -1.0 ALL_TRUSTED            Passed through trusted hosts only via SMTP
 -1.9 BAYES_00               BODY: Bayes spam probability is 0 to 1%
 [score: 0.0000]
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 43441
Cc: 43441 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Alex Bochannek <alex@HIDDEN> writes:

> I don't suspect this problem is widespread in other uses of the base64
> decoder, so it seems appropriate to me to just patch
> gnus-convert-face-to-png to generate the right amount of padding.

Hm...  I think it would be nice to have a utility function to fix up
base64 padding, and then gnus-convert-face-to-png could just use that?

It should work for both base64 that has newlines inserted and not.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#43441; Package emacs. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 16 Sep 2020 06:07:08 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Sep 16 02:07:08 2020
Received: from localhost ([127.0.0.1]:32968 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1kIQay-0001qk-1P
	for submit <at> debbugs.gnu.org; Wed, 16 Sep 2020 02:07:08 -0400
Received: from lists.gnu.org ([209.51.188.17]:54440)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <alex@HIDDEN>) id 1kIQaw-0001qd-29
 for submit <at> debbugs.gnu.org; Wed, 16 Sep 2020 02:07:07 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10]:57938)
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <alex@HIDDEN>)
 id 1kIQav-00066U-Tj
 for bug-gnu-emacs@HIDDEN; Wed, 16 Sep 2020 02:07:05 -0400
Received: from 50-0-39-243.dsl.static.fusionbroadband.com ([50.0.39.243]:35082
 helo=mail.lapseofthought.com)
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <alex@HIDDEN>)
 id 1kIQaq-00053j-Ht
 for bug-gnu-emacs@HIDDEN; Wed, 16 Sep 2020 02:07:04 -0400
Received: from localhost (localhost [127.0.0.1])
 by mail.lapseofthought.com (Postfix) with ESMTP id 4BrqPC4nXDz3jjXb
 for <bug-gnu-emacs@HIDDEN>; Tue, 15 Sep 2020 23:06:55 -0700 (PDT)
X-Virus-Scanned: Debian amavisd-new at lapseofthought.com
Received: from mail.lapseofthought.com ([127.0.0.1])
 by localhost (mail.lapseofthought.com [127.0.0.1]) (amavisd-new, port 10024)
 with ESMTP id kssvzpc3i_9E for <bug-gnu-emacs@HIDDEN>;
 Tue, 15 Sep 2020 23:06:54 -0700 (PDT)
Received: from awb-mbp.local (unknown
 [IPv6:2601:646:4200:b470:b0ed:26e8:d479:c855])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits))
 (No client certificate requested)
 by mail.lapseofthought.com (Postfix) with ESMTPSA id 4BrqPB0kF3z3jhcB
 for <bug-gnu-emacs@HIDDEN>; Tue, 15 Sep 2020 23:06:54 -0700 (PDT)
From: Alex Bochannek <alex@HIDDEN>
To: bug-gnu-emacs@HIDDEN
Subject: 27.1; [PATCH] Fix incorrectly base64-padded faces in
 gnus-convert-face-to-png
Date: Tue, 15 Sep 2020 23:06:53 -0700
Message-ID: <m2ft7i9rwi.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (darwin)
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="=-=-="
Received-SPF: softfail client-ip=50.0.39.243; envelope-from=alex@HIDDEN;
 helo=mail.lapseofthought.com
X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/16 02:06:56
X-ACL-Warn: Detected OS   = Linux 2.2.x-3.x [generic] [fuzzy]
X-Spam_score_int: 2
X-Spam_score: 0.2
X-Spam_bar: /
X-Spam_report: (0.2 / 5.0 requ) BAYES_00=-1.9, FORGED_SPF_HELO=1,
 KHOP_HELO_FCRDNS=0.399, SPF_HELO_PASS=-0.001, SPF_SOFTFAIL=0.665,
 TVD_RCVD_IP=0.001 autolearn=no autolearn_force=no
X-Spam_action: no action
X-Spam-Score: -1.3 (-)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -2.3 (--)

--=-=-=
Content-Type: text/plain

Hello!

I noticed a problem with Faces not showing up despite a Face-header
being present in a message. In this particular case,
base64-decode-region failed to decode the header, which had incorrect
(i.e., excessive) padding. A command line and a Web-based decoder
happily ignored the superfluous '='s at the end of the string. Here is
the string in question:

"iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAMFBMVEUwXjFLc0vD0cS7y7zw9PDZ4tkWSRaVrZZ+m39qi2tXfVj////7+/utwK4IPggAOAAJUUA7AAABKklEQVQ4jWPYjQMwDFYJp0NKEKCNJmEf9h8CsimXiL2e33s3/e7F7K2Cs3f3dCMkQkMKj4YuCY3K3iR+e7fMaiSjvkX0/5cFGrWpe2uLzOpaExUVqMS/8PX/Re5ey960OLBTZpFA8+IlSBKPQ92zNyUUBsosN58uIY0k8f+/ONCoYytkVuhWzVwNkYiYbqk5M3NmOVBi41YZ8RsGF7shEtFb5KJ3r969CyixM7OTPeFUxG2IxLO8/9/SvqXlc+/x3h295YzLlj2nIRJQj//nRvc5TEIal8RsXBLVuCQwIgoq/u80DomP6HEOk/iOS+IJLonZOCT+ReOQ+Lkbh0QKLonbOCR+7MYhsRqHBJrVcIl/1TgklqKLQyQ+tGKIgyQOqXpjig94diZRAgAXmDX6jyWafAAAAABJRU5ErkJggg======"

The correct number of '='s here is two.

I don't suspect this problem is widespread in other uses of the base64
decoder, so it seems appropriate to me to just patch
gnus-convert-face-to-png to generate the right amount of padding.


--=-=-=
Content-Type: text/x-patch
Content-Disposition: inline
Content-Description: Fix incorrectly base64-padded faces in gnus-convert-face-to-png

diff --git a/lisp/gnus/gnus-fun.el b/lisp/gnus/gnus-fun.el
index c95449762e..f1773db29a 100644
--- a/lisp/gnus/gnus-fun.el
+++ b/lisp/gnus/gnus-fun.el
@@ -205,11 +205,27 @@ gnus-face-encode
 (defun gnus-convert-face-to-png (face)
   "Convert FACE (which is base64-encoded) to a PNG.
 The PNG is returned as a string."
-  (mm-with-unibyte-buffer
-    (insert face)
-    (ignore-errors
-      (base64-decode-region (point-min) (point-max)))
-    (buffer-string)))
+  (let ((face (replace-regexp-in-string "[^[:graph:]]" "" face)))
+    ;; Calculate correct base64 padding
+    (if (string-match "=" face)
+	(let ((length (match-beginning 0))
+	      (padding nil))
+	  (progn (setq padding
+		       (/
+			(- 24
+			   (pcase (mod (* length 6) 24)
+			     (`0 24)
+			     (n n)))
+			6))
+		 (setq face (concat
+			     (substring face 0
+					(match-beginning 0))
+			     (make-string padding ?=))))))
+    (mm-with-unibyte-buffer
+      (insert face)
+      (ignore-errors
+	(base64-decode-region (point-min) (point-max)))
+      (buffer-string))))
 
 ;;;###autoload
 (defun gnus-convert-png-to-face (file)

--=-=-=
Content-Type: text/plain


-- 
Alex. (abochannek@HIDDEN)

--=-=-=--




Acknowledgement sent to Alex Bochannek <alex@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs@HIDDEN. Full text available.
Report forwarded to bug-gnu-emacs@HIDDEN:
bug#43441; Package emacs. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Thu, 17 Sep 2020 15:45:01 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.