From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Ken Olum Newsgroups: gmane.emacs.bugs Subject: bug#28671: 25.2; double transfer-encoding in rmailedit for complex mime messages Date: Mon, 02 Oct 2017 11:37:46 -0400 Message-ID: NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: blaine.gmane.org 1506959480 4180 195.159.176.226 (2 Oct 2017 15:51:20 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 2 Oct 2017 15:51:20 +0000 (UTC) Cc: kdo@cosmos.phy.tufts.edu To: 28671@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Oct 02 17:51:14 2017 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 1dz2zu-0000S6-Qd for geb-bug-gnu-emacs@m.gmane.org; Mon, 02 Oct 2017 17:51:11 +0200 Original-Received: from localhost ([::1]:52937 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dz302-0005jZ-3v for geb-bug-gnu-emacs@m.gmane.org; Mon, 02 Oct 2017 11:51:18 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:43167) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dz2oD-00025k-Oh for bug-gnu-emacs@gnu.org; Mon, 02 Oct 2017 11:39:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dz2oA-0008AM-LP for bug-gnu-emacs@gnu.org; Mon, 02 Oct 2017 11:39:05 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:35668) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dz2oA-0008AF-GU for bug-gnu-emacs@gnu.org; Mon, 02 Oct 2017 11:39:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1dz2oA-0004PM-A9 for bug-gnu-emacs@gnu.org; Mon, 02 Oct 2017 11:39:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Ken Olum Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 02 Oct 2017 15:39:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 28671 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.150695868716867 (code B ref -1); Mon, 02 Oct 2017 15:39:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 2 Oct 2017 15:38:07 +0000 Original-Received: from localhost ([127.0.0.1]:44348 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dz2nG-0004Ny-5m for submit@debbugs.gnu.org; Mon, 02 Oct 2017 11:38:06 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:51777) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dz2nD-0004N5-IN for submit@debbugs.gnu.org; Mon, 02 Oct 2017 11:38:04 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dz2n6-0007UN-TG for submit@debbugs.gnu.org; Mon, 02 Oct 2017 11:37:58 -0400 Original-Received: from lists.gnu.org ([2001:4830:134:3::11]:42812) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dz2n6-0007U0-Ql for submit@debbugs.gnu.org; Mon, 02 Oct 2017 11:37:56 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:42746) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dz2n5-0001Bh-CZ for bug-gnu-emacs@gnu.org; Mon, 02 Oct 2017 11:37:56 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dz2n2-0007RW-8t for bug-gnu-emacs@gnu.org; Mon, 02 Oct 2017 11:37:55 -0400 Original-Received: from cosmos.phy.tufts.edu ([130.64.84.253]:52966) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dz2n2-0007OY-4q for bug-gnu-emacs@gnu.org; Mon, 02 Oct 2017 11:37:52 -0400 Original-Received: from kdo by cosmos.phy.tufts.edu ([local]:local) with local id 1dz2mw-0001Xk-98 - Using Exim-4.84 (MandrivaLinux) MTA (return-path ); Mon, 02 Oct 2017 11:37:46 -0400 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x 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:137777 Archived-At: --=-=-= Content-Type: text/plain When rmail-edit-current-message gets a mime message which is too complex for it to handle (i.e., anything but one "text/plain" part), it just gives you the raw message to edit. If you do so, rmail-cease-edit then applies the transfer-encoding even though the message wasn't decoded, and so on. It also in some circumstances it also moves the marker for the beginning of the following message. The attached patch modifies rmail-cease-edit to check the rmail-old-mime-state flag set by rmail-edit-current-message when it is editing the raw message. If set, rmail-cease-edit inserts the already-encoded body without further processing. It also deletes the old body after inserting the new, rather than before, to avoid moving the next message's marker. Ken In GNU Emacs 25.2.2 (x86_64-unknown-linux-gnu, X toolkit, Xaw scroll bars) of 2017-05-29 built on olum.org Windowing system distributor 'The X.Org Foundation', version 11.0.11804000 System Description: Ubuntu 16.04.3 LTS Configured features: XPM JPEG TIFF GIF PNG SOUND NOTIFY FREETYPE XFT ZLIB TOOLKIT_SCROLL_BARS LUCID X11 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=rmailedit.patch --- lisp/mail/rmailedit.el 2017-07-06 10:27:25.654906559 -0400 +++ lisp/mail/rmailedit.new.el 2017-09-26 12:00:45.498641338 -0400 @@ -312,26 +312,34 @@ (data-buffer (current-buffer)) (start (copy-marker (point) nil)) ; new body will be between (end (copy-marker (point) t))) ; these two markers - (with-current-buffer rmail-view-buffer - (encode-coding-region headers-end (point-max) coding-system - data-buffer)) - (delete-region end (point-max)) + (if mime-state + ;; Message is already in encoded state + (insert-buffer-substring rmail-view-buffer headers-end + (with-current-buffer rmail-view-buffer + (point-max))) + (with-current-buffer rmail-view-buffer + (encode-coding-region headers-end (point-max) coding-system + data-buffer))) ;; Apply to the mbox buffer any changes in header fields ;; that the user made while editing in the view buffer. (rmail-edit-update-headers (rmail-edit-diff-headers rmail-old-headers new-headers)) ;; Re-apply content-transfer-encoding, if any, on the message body. - (cond - ((string= character-coding "quoted-printable") - (mail-quote-printable-region start (point-max))) - ((and (string= character-coding "base64") is-text-message) - (base64-encode-region start (point-max))) - ((and (eq character-coding 'uuencode) is-text-message) - (error "uuencoded messages are not supported"))) + (unless mime-state ; if set, already transfer-encoded + (cond + ((string= character-coding "quoted-printable") + (mail-quote-printable-region start end)) + ((and (string= character-coding "base64") is-text-message) + (base64-encode-region start end)) + ((and (eq character-coding 'uuencode) is-text-message) + (error "uuencoded messages are not supported")))) ;; After encoding, make sure buffer ends with a blank line so as not to ;; run this message together with the following one. - (goto-char (point-max)) - (rmail-ensure-blank-line)) + (goto-char end) + (rmail-ensure-blank-line) + ;; Delete previous body. This must be after all insertions at the end, + ;; so the marker for the beginning of the next message isn't messed up. + (delete-region end (point-max))) (rmail-set-attribute rmail-edited-attr-index t)) ;;;??? BROKEN perhaps. ;;; (if (boundp 'rmail-summary-vector) --=-=-=--