unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* [PATCH 1/2] test/emacs: test saving of attachment containing 8bit octets
       [not found] <id:87txsm23hs.fsf@betacantrips.com>
@ 2012-11-18 20:06 ` Tomi Ollila
  2012-11-18 20:06   ` [PATCH 2/2] emacs: less guessing of character set in messages Tomi Ollila
  2012-11-27  2:10   ` [PATCH 1/2] test/emacs: test saving of attachment containing 8bit octets David Bremner
  0 siblings, 2 replies; 5+ messages in thread
From: Tomi Ollila @ 2012-11-18 20:06 UTC (permalink / raw)
  To: notmuch; +Cc: tomi.ollila

This test catches the case 8bit octets in an attachment gets converted
or lost when saving attachment to the file.
This test is marked known broken.
---
 test/emacs | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/test/emacs b/test/emacs
index 77265b0..c8db7d0 100755
--- a/test/emacs
+++ b/test/emacs
@@ -516,6 +516,33 @@ test_emacs '(let ((standard-input "\"attachment2.gz\""))
 	      (notmuch-show-save-part "id:cf0c4d610911171136h1713aa59w9cf9aa31f052ad0a@mail.gmail.com" 5))'
 test_expect_equal_file attachment2.gz "$EXPECTED/attachment"
 
+test_begin_subtest "Save 8bit attachment from within emacs using notmuch-show-save-attachments"
+test_subtest_known_broken
+
+add_message '[subject]="Attachment with 8bit chars"' \
+	'[header]="MIME-Version: 1.0"' \
+	'[content-type]="multipart/mixed; boundary=\"abcd\""' \
+	'[body]="--abcd
+Content-Type: text/plain
+
+Attachment follows:
+
+--abcd
+Content-Type: application/octet-stream; name=\"sample\"
+Content-Transfer-Encoding: 8bit
+Content-Disposition: attachment; filename=\"sample\"
+
+“¡ Hey ! It compiles ¡ Ship it !”
+
+--abcd--
+"'
+test_emacs '(notmuch-show "id:'"${gen_msg_id}"'")
+	    (delete-file "OUTPUT")
+	    (let ((standard-input "\"OUTPUT\""))
+	      (notmuch-show-save-attachments))'
+
+test_expect_equal "$(cat OUTPUT)" '“¡ Hey ! It compiles ¡ Ship it !”'
+
 test_begin_subtest "View raw message within emacs"
 test_emacs '(notmuch-show "id:cf0c4d610911171136h1713aa59w9cf9aa31f052ad0a@mail.gmail.com")
 	    (notmuch-show-view-raw-message)
-- 
1.8.0

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/2] emacs: less guessing of character set in messages
  2012-11-18 20:06 ` [PATCH 1/2] test/emacs: test saving of attachment containing 8bit octets Tomi Ollila
@ 2012-11-18 20:06   ` Tomi Ollila
  2012-11-18 20:25     ` Ethan Glasser-Camp
  2012-11-27  2:10   ` [PATCH 1/2] test/emacs: test saving of attachment containing 8bit octets David Bremner
  1 sibling, 1 reply; 5+ messages in thread
From: Tomi Ollila @ 2012-11-18 20:06 UTC (permalink / raw)
  To: notmuch; +Cc: tomi.ollila

The macro with-current-notmuch-show-message executes command
`notmuch show --format=raw id:...` which just outputs the contents
of the mail file verbatim (into temporary buffer). In case e.g. utf-8
locale is used the temporary buffer has buffer-file-coding-system as
utf-8. In this case Emacs converts the data to multibyte format, guessing
that input is in utf-8.
However, the "raw" (MIME) message may contain octet data in any other
8bit format, and as no (MIME-)content spesific handling to the message
is done at this point, conversion to other formats may lose information.
By setting coding-system-for-read 'no-conversion drops the conversion part
and makes this handle input as notmuch-get-bodypart-internal() does.
This marks the broken test in previous change fixed.
---
 emacs/notmuch-show.el | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 5b3e70e..44b6f35 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -203,9 +203,10 @@ For example, if you wanted to remove an \"unread\" tag and add a
      (let ((id (notmuch-show-get-message-id)))
        (let ((buf (generate-new-buffer (concat "*notmuch-msg-" id "*"))))
          (with-current-buffer buf
-	    (call-process notmuch-command nil t nil "show" "--format=raw" id)
-           ,@body)
-	 (kill-buffer buf)))))
+	   (let ((coding-system-for-read 'no-conversion))
+	     (call-process notmuch-command nil t nil "show" "--format=raw" id)
+	     ,@body)
+	   (kill-buffer buf))))))
 
 (defun notmuch-show-turn-on-visual-line-mode ()
   "Enable Visual Line mode."
-- 
1.8.0

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 2/2] emacs: less guessing of character set in messages
  2012-11-18 20:06   ` [PATCH 2/2] emacs: less guessing of character set in messages Tomi Ollila
@ 2012-11-18 20:25     ` Ethan Glasser-Camp
  0 siblings, 0 replies; 5+ messages in thread
From: Ethan Glasser-Camp @ 2012-11-18 20:25 UTC (permalink / raw)
  To: Tomi Ollila, notmuch; +Cc: tomi.ollila

Tomi Ollila <tomi.ollila@iki.fi> writes:

> The macro with-current-notmuch-show-message executes command
> `notmuch show --format=raw id:...` which just outputs the contents
> of the mail file verbatim (into temporary buffer). In case e.g. utf-8
> locale is used the temporary buffer has buffer-file-coding-system as
> utf-8. In this case Emacs converts the data to multibyte format, guessing
> that input is in utf-8.
> However, the "raw" (MIME) message may contain octet data in any other
> 8bit format, and as no (MIME-)content spesific handling to the message
> is done at this point, conversion to other formats may lose information.
> By setting coding-system-for-read 'no-conversion drops the conversion part
> and makes this handle input as notmuch-get-bodypart-internal() does.
> This marks the broken test in previous change fixed.

This looks good to me, though you might need to apply it with notmuch
show --format="mbox" :).

Ethan

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/2] test/emacs: test saving of attachment containing 8bit octets
  2012-11-18 20:06 ` [PATCH 1/2] test/emacs: test saving of attachment containing 8bit octets Tomi Ollila
  2012-11-18 20:06   ` [PATCH 2/2] emacs: less guessing of character set in messages Tomi Ollila
@ 2012-11-27  2:10   ` David Bremner
  2012-11-27 10:05     ` Tomi Ollila
  1 sibling, 1 reply; 5+ messages in thread
From: David Bremner @ 2012-11-27  2:10 UTC (permalink / raw)
  To: Tomi Ollila, notmuch; +Cc: tomi.ollila

Tomi Ollila <tomi.ollila@iki.fi> writes:

> This test catches the case 8bit octets in an attachment gets converted
> or lost when saving attachment to the file.
> This test is marked known broken.

I pushed both, but I took the liberty of amending the second to actually
mark the test as fixed (i.e. removed the known broken line). Hopefully
that's what you meant to do.

d

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/2] test/emacs: test saving of attachment containing 8bit octets
  2012-11-27  2:10   ` [PATCH 1/2] test/emacs: test saving of attachment containing 8bit octets David Bremner
@ 2012-11-27 10:05     ` Tomi Ollila
  0 siblings, 0 replies; 5+ messages in thread
From: Tomi Ollila @ 2012-11-27 10:05 UTC (permalink / raw)
  To: David Bremner, notmuch

On Tue, Nov 27 2012, David Bremner wrote:

> Tomi Ollila <tomi.ollila@iki.fi> writes:
>
>> This test catches the case 8bit octets in an attachment gets converted
>> or lost when saving attachment to the file.
>> This test is marked known broken.
>
> I pushed both, but I took the liberty of amending the second to actually
> mark the test as fixed (i.e. removed the known broken line). Hopefully
> that's what you meant to do.

tnx!

> d

Tomi

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2012-11-27 10:05 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <id:87txsm23hs.fsf@betacantrips.com>
2012-11-18 20:06 ` [PATCH 1/2] test/emacs: test saving of attachment containing 8bit octets Tomi Ollila
2012-11-18 20:06   ` [PATCH 2/2] emacs: less guessing of character set in messages Tomi Ollila
2012-11-18 20:25     ` Ethan Glasser-Camp
2012-11-27  2:10   ` [PATCH 1/2] test/emacs: test saving of attachment containing 8bit octets David Bremner
2012-11-27 10:05     ` Tomi Ollila

Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).