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 13:47:20 -0400 Message-ID: References: NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: blaine.gmane.org 1506966492 30830 195.159.176.226 (2 Oct 2017 17:48:12 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 2 Oct 2017 17:48:12 +0000 (UTC) Cc: kdo@cosmos.phy.tufts.edu, 28671@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Oct 02 19:48:06 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 1dz4p3-0007O1-8J for geb-bug-gnu-emacs@m.gmane.org; Mon, 02 Oct 2017 19:48:05 +0200 Original-Received: from localhost ([::1]:53566 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dz4pA-0005mr-O9 for geb-bug-gnu-emacs@m.gmane.org; Mon, 02 Oct 2017 13:48:12 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:41616) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dz4p3-0005ma-Dx for bug-gnu-emacs@gnu.org; Mon, 02 Oct 2017 13:48:06 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dz4p0-0006aJ-Ap for bug-gnu-emacs@gnu.org; Mon, 02 Oct 2017 13:48:05 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:35809) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dz4p0-0006a4-4v for bug-gnu-emacs@gnu.org; Mon, 02 Oct 2017 13:48:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1dz4oz-0001H8-Nh for bug-gnu-emacs@gnu.org; Mon, 02 Oct 2017 13:48:01 -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 17:48:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 28671 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 28671-submit@debbugs.gnu.org id=B28671.15069664464856 (code B ref 28671); Mon, 02 Oct 2017 17:48:01 +0000 Original-Received: (at 28671) by debbugs.gnu.org; 2 Oct 2017 17:47:26 +0000 Original-Received: from localhost ([127.0.0.1]:44490 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dz4oQ-0001GF-As for submit@debbugs.gnu.org; Mon, 02 Oct 2017 13:47:26 -0400 Original-Received: from cosmos.phy.tufts.edu ([130.64.84.253]:44884) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dz4oM-0001G6-Uc for 28671@debbugs.gnu.org; Mon, 02 Oct 2017 13:47:23 -0400 Original-Received: from kdo by cosmos.phy.tufts.edu ([local]:local) with local id 1dz4oK-0005nG-6i - Using Exim-4.84 (MandrivaLinux) MTA (return-path ); Mon, 02 Oct 2017 13:47:20 -0400 In-Reply-To: <834lrh33q4.fsf@gnu.org> (message from Eli Zaretskii on Mon, 02 Oct 2017 19:37:55 +0300) 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:137797 Archived-At: --=-=-= Content-Type: text/plain Here is a test file. Edit the first message and make some change (e.g., to the subject header). Then the body will end up base64 encoded twice. If you then go to the next message, the headers will have extra lines at the top due to marker problems. The patch should fix these problems. Here's a new patch with the simplified code as you suggested, and here's a change log entry: ---------------------------------------------------------------------- 2017-10-02 Ken Olum Fix problems when editing raw message (Bug#28671) * lisp/mail/rmailedit.el (rmail-cease-edit): if rmail-old-mime-state is set, meaning that we are editing the raw message, do not encode it again. Delete old body after, not before, inserting new, to avoid moving marker at beginning of next message. ---------------------------------------------------------------------- Ken --=-=-= Content-Type: application/octet-stream Content-Disposition: attachment; filename=rmail-test Content-Transfer-Encoding: base64 RnJvbSBrZG9AY29zbW9zLnBoeS50dWZ0cy5lZHUgVGh1IEF1ZyAzMSAxMDoxNToxNCAyMDE3Ck1J TUUtVmVyc2lvbjogMS4wCkZyb206IDxrZG9AY29zbW9zLnBoeS50dWZ0cy5lZHU+ClRvOiA8a2Rv QGNvc21vcy5waHkudHVmdHMuZWR1PgpEYXRlOiBUaHUsIDMxIEF1ZyAyMDE3IDEwOjEwOjQwIC0w NDAwClN1YmplY3Q6IFRlc3QgbWVzc2FnZQpDb250ZW50LVR5cGU6IHRleHQvaHRtbDsgY2hhcnNl dD0idXRmLTgiCkNvbnRlbnQtVHJhbnNmZXItRW5jb2Rpbmc6IGJhc2U2NApNZXNzYWdlLUlEOiA8 ZjFkNzA5YjM4NmJiNDJhNmEwYTZlYmMxNWUzYTI4MDNAUFBFMjAxMzIuTUJUQS5DT00+ClgtUk1B SUwtQVRUUklCVVRFUzogLS1FLS0tLS0KClZHaHBjeUJwY3lCaElIUmxjM1FLCgpGcm9tIGtkb0Bj b3Ntb3MucGh5LnR1ZnRzLmVkdSBNb24gT2N0IDAyIDEzOjIwOjE3IDIwMTcKUmV0dXJuLXBhdGg6 IDxrZG9AY29zbW9zLnBoeS50dWZ0cy5lZHU+CkVudmVsb3BlLXRvOiBrZG9AY29zbW9zLnBoeS50 dWZ0cy5lZHUKRGVsaXZlcnktZGF0ZTogTW9uLCAwMiBPY3QgMjAxNyAxMzoyMDoxNyAtMDQwMApS ZWNlaXZlZDogZnJvbSBrZG8gYnkgY29zbW9zLnBoeS50dWZ0cy5lZHUgKFtsb2NhbF06bG9jYWwp Cgl3aXRoIGxvY2FsIGlkIDFkejRPOS0wMDA1UlAtNGEgLSBVc2luZyBFeGltLTQuODQgKE1hbmRy aXZhTGludXgpIE1UQSAKCShyZXR1cm4tcGF0aCA8a2RvQGNvc21vcy5waHkudHVmdHMuZWR1Pik7 IE1vbiwgMDIgT2N0IDIwMTcgMTM6MjA6MTcgLTA0MDAKRnJvbTogS2VuIE9sdW0gPGtkb0Bjb3Nt b3MucGh5LnR1ZnRzLmVkdT4KVG86IGtkb0Bjb3Ntb3MucGh5LnR1ZnRzLmVkdQpTdWJqZWN0OiBz ZWNvbmQgdGVzdCBtZXNzYWdlCkRhdGU6IE1vbiwgMDIgT2N0IDIwMTcgMTM6MjA6MTcgLTA0MDAK TWVzc2FnZS1JRDogPHE1MmVmcWx4eTlhLmZzZkBjb3Ntb3MucGh5LnR1ZnRzLmVkdT4KTUlNRS1W ZXJzaW9uOiAxLjAKQ29udGVudC1UeXBlOiB0ZXh0L3BsYWluOyBjaGFyc2V0PXVzLWFzY2lpClgt Uk1BSUwtQVRUUklCVVRFUzogLS0tLS0tLS0KCgo= --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=rmailedit.patch --- lisp/mail/rmailedit.old.el 2017-07-06 10:27:25.654906559 -0400 +++ lisp/mail/rmailedit.el 2017-10-02 13:44:25.050239587 -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-edit-update-headers (rmail-edit-diff-headers rmail-old-headers new-headers)) ;; Re-apply content-transfer-encoding, if any, on the message body. (cond + (mime-state) ; if set, already transfer-encoded ((string= character-coding "quoted-printable") - (mail-quote-printable-region start (point-max))) + (mail-quote-printable-region start end)) ((and (string= character-coding "base64") is-text-message) - (base64-encode-region start (point-max))) + (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) --=-=-=--