Gnus development mailing list
 help / color / mirror / Atom feed
* BUG: `gnus-article-browse-html-article' not displaying inline html images
@ 2010-03-26 17:56 Eric Schulte
  2010-03-27  5:09 ` Ted Zlatanov
  0 siblings, 1 reply; 9+ messages in thread
From: Eric Schulte @ 2010-03-26 17:56 UTC (permalink / raw)
  To: ding

Hi,

I've noticed recently that `gnus-article-browse-html-article' (K H) does
not display image attachments referenced from text/html portions of the
email body.

So for example, when viewed as html, something like

<img src="cid:image-id"/>

should be replaced by the attached image with the "Content-ID" of
"image-id".  While this sort of rendering *does* work in the gmail web
interface, it does not work with `gnus-article-browse-html-article'.

Thanks -- Eric

p.s. I've been using gnus for some years now, and playing around with
the code some recently, and it is a pleasure to use such a stable well
designed piece of software. Thanks!



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

* Re: BUG: `gnus-article-browse-html-article' not displaying inline html images
  2010-03-26 17:56 BUG: `gnus-article-browse-html-article' not displaying inline html images Eric Schulte
@ 2010-03-27  5:09 ` Ted Zlatanov
  2010-03-27 13:26   ` Eric Schulte
  0 siblings, 1 reply; 9+ messages in thread
From: Ted Zlatanov @ 2010-03-27  5:09 UTC (permalink / raw)
  To: Eric Schulte; +Cc: ding

On Fri, 26 Mar 2010 11:56:19 -0600 "Eric Schulte" <schulte.eric@gmail.com> wrote: 

ES> I've noticed recently that `gnus-article-browse-html-article' (K H) does
ES> not display image attachments referenced from text/html portions of the
ES> email body.

ES> So for example, when viewed as html, something like

ES> <img src="cid:image-id"/>

ES> should be replaced by the attached image with the "Content-ID" of
ES> "image-id".  While this sort of rendering *does* work in the gmail web
ES> interface, it does not work with `gnus-article-browse-html-article'.

Here's some info from a past thread on this topic:

http://www.mail-archive.com/info-gnus-english@gnu.org/msg02931.html

Short answer: cid: links are disabled, you can enable them with:

(setq mm-w3m-safe-url-regexp nil
      w3m-default-display-inline-images t)

Ted



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

* Re: BUG: `gnus-article-browse-html-article' not displaying inline html images
  2010-03-27  5:09 ` Ted Zlatanov
@ 2010-03-27 13:26   ` Eric Schulte
  2010-03-29 18:15     ` [PATCH] " Eric Schulte
  0 siblings, 1 reply; 9+ messages in thread
From: Eric Schulte @ 2010-03-27 13:26 UTC (permalink / raw)
  To: Ted Zlatanov; +Cc: ding

Ted Zlatanov <tzz@lifelogs.com> writes:

> On Fri, 26 Mar 2010 11:56:19 -0600 "Eric Schulte" <schulte.eric@gmail.com> wrote: 
>
> ES> I've noticed recently that `gnus-article-browse-html-article' (K H) does
> ES> not display image attachments referenced from text/html portions of the
> ES> email body.
>
> ES> So for example, when viewed as html, something like
>
> ES> <img src="cid:image-id"/>
>
> ES> should be replaced by the attached image with the "Content-ID" of
> ES> "image-id".  While this sort of rendering *does* work in the gmail web
> ES> interface, it does not work with `gnus-article-browse-html-article'.
>
> Here's some info from a past thread on this topic:
>
> http://www.mail-archive.com/info-gnus-english@gnu.org/msg02931.html
>
> Short answer: cid: links are disabled, you can enable them with:
>
> (setq mm-w3m-safe-url-regexp nil
>       w3m-default-display-inline-images t)
>

Hi Ted,

While I have been able to display cid images inline in my Emacs buffer
with w3m, my problem arises when I use gnus-article-browse-html-article
(K H from an *Article* buffer) to view html email in my web browser.

The cid images are not written out to temporary files where they can be
resolved from the temporary html file.  The above settings don't affect
this behavior.

Thanks -- Eric

>
> Ted



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

* Re: [PATCH] `gnus-article-browse-html-article' not displaying inline html images
  2010-03-27 13:26   ` Eric Schulte
@ 2010-03-29 18:15     ` Eric Schulte
  2010-03-30  0:24       ` Katsumi Yamaoka
  0 siblings, 1 reply; 9+ messages in thread
From: Eric Schulte @ 2010-03-29 18:15 UTC (permalink / raw)
  To: Ted Zlatanov; +Cc: ding

[-- Attachment #1: Type: text/plain, Size: 102 bytes --]

Hi,

The attached patch fixes this issue by writing cid images out to
temporary files.

Best -- Eric


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: gnus-art-cid-images.patch --]
[-- Type: text/x-diff, Size: 2291 bytes --]

diff --git a/lisp/gnus/gnus-art.el b/lisp/gnus/gnus-art.el
index 6bc84e4..7cd3c12 100644
--- a/lisp/gnus/gnus-art.el
+++ b/lisp/gnus/gnus-art.el
@@ -2939,6 +2939,35 @@ message header will be added to the bodies of the \"text/html\" parts."
 		       (re-search-forward
 			"</head\\(?:\\s-+[^>]+\\|\\s-*\\)>\\s-*" nil t))
 		   (insert eheader)
+                   ;; resolve cid images
+                   (let (cid-image-dir)
+                     (flet ((save-cid-image (cid)
+                              (gnus-with-article-buffer
+                                (let (cid-handle cid-tmp-file)
+                                  (mapc
+                                   (lambda (handle)
+                                     (when (and (listp handle)
+                                                (stringp (car (last handle)))
+                                                (string= (format "<%s>" cid)
+                                                         (car (last handle))))
+                                       (setq cid-handle handle)
+                                       (setq cid-tmp-file
+                                             (expand-file-name
+                                              (cdr (assoc 'filename
+                                                          (cdr (nth 4 handle))))
+                                              cid-image-dir))))
+                                   gnus-article-mime-handles)
+                                  (when (and cid-handle cid-tmp-file)
+                                    (mm-save-part-to-file cid-handle cid-tmp-file)
+                                    cid-tmp-file)))))
+                       (goto-char (point-min))
+                       (while (re-search-forward "<img src=\"\\(cid:\\([^\"]+\\)\\)\""
+                                                 nil t)
+                         (unless cid-image-dir
+                           (setq cid-image-dir (make-temp-file "cid" t)))
+                         (replace-match (save-match-data
+                                          (save-cid-image (match-string 2)))
+                                        nil nil nil 1))))
 		   (mm-write-region (point-min) (point-max)
 				    tmp-file nil nil nil 'binary t))))
 	      (charset

[-- Attachment #3: Type: text/plain, Size: 1409 bytes --]


"Eric Schulte" <schulte.eric@gmail.com> writes:

> Ted Zlatanov <tzz@lifelogs.com> writes:
>
>> On Fri, 26 Mar 2010 11:56:19 -0600 "Eric Schulte" <schulte.eric@gmail.com> wrote: 
>>
>> ES> I've noticed recently that `gnus-article-browse-html-article' (K H) does
>> ES> not display image attachments referenced from text/html portions of the
>> ES> email body.
>>
>> ES> So for example, when viewed as html, something like
>>
>> ES> <img src="cid:image-id"/>
>>
>> ES> should be replaced by the attached image with the "Content-ID" of
>> ES> "image-id".  While this sort of rendering *does* work in the gmail web
>> ES> interface, it does not work with `gnus-article-browse-html-article'.
>>
>> Here's some info from a past thread on this topic:
>>
>> http://www.mail-archive.com/info-gnus-english@gnu.org/msg02931.html
>>
>> Short answer: cid: links are disabled, you can enable them with:
>>
>> (setq mm-w3m-safe-url-regexp nil
>>       w3m-default-display-inline-images t)
>>
>
> Hi Ted,
>
> While I have been able to display cid images inline in my Emacs buffer
> with w3m, my problem arises when I use gnus-article-browse-html-article
> (K H from an *Article* buffer) to view html email in my web browser.
>
> The cid images are not written out to temporary files where they can be
> resolved from the temporary html file.  The above settings don't affect
> this behavior.
>
> Thanks -- Eric
>
>>
>> Ted

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

* Re: [PATCH] `gnus-article-browse-html-article' not displaying inline html images
  2010-03-29 18:15     ` [PATCH] " Eric Schulte
@ 2010-03-30  0:24       ` Katsumi Yamaoka
  2010-03-30  1:10         ` Eric Schulte
  0 siblings, 1 reply; 9+ messages in thread
From: Katsumi Yamaoka @ 2010-03-30  0:24 UTC (permalink / raw)
  To: ding

[-- Attachment #1: Type: text/plain, Size: 416 bytes --]

>>>>> Eric Schulte wrote:
> The attached patch fixes this issue by writing cid images out to
> temporary files.

Wonderful!  But I needed to improve it slightly to work.  Could
you see the attached new patch?   It works with images that do
not specify file names, deletes temp directory, inserts header
at the right place, etc.  An example article is also attached.

BTW, have you signed a paper for Gnus or Emacs?


[-- Attachment #2: gnus-art-cid-images-2_patch.gz --]
[-- Type: application/x-gzip, Size: 963 bytes --]

[-- Attachment #3: art-example.gz --]
[-- Type: application/x-gzip, Size: 42826 bytes --]

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

* Re: [PATCH] `gnus-article-browse-html-article' not displaying inline html images
  2010-03-30  0:24       ` Katsumi Yamaoka
@ 2010-03-30  1:10         ` Eric Schulte
  2010-03-30  4:06           ` Katsumi Yamaoka
  0 siblings, 1 reply; 9+ messages in thread
From: Eric Schulte @ 2010-03-30  1:10 UTC (permalink / raw)
  To: Katsumi Yamaoka; +Cc: ding

Katsumi Yamaoka <yamaoka@jpl.org> writes:

>>>>>> Eric Schulte wrote:
>> The attached patch fixes this issue by writing cid images out to
>> temporary files.
>
> Wonderful!  But I needed to improve it slightly to work.  Could
> you see the attached new patch?   It works with images that do
> not specify file names, deletes temp directory, inserts header
> at the right place, etc.  An example article is also attached.
>

The new patch looks great, thanks for taking this the rest of the way.

>
> BTW, have you signed a paper for Gnus or Emacs?

Yes, I've signed the Emacs papers, and have previously contributed to
Org-mode, so it should be fine for inclusion.

Thanks -- Eric



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

* Re: [PATCH] `gnus-article-browse-html-article' not displaying inline html images
  2010-03-30  1:10         ` Eric Schulte
@ 2010-03-30  4:06           ` Katsumi Yamaoka
  2010-03-30 13:36             ` Ted Zlatanov
  0 siblings, 1 reply; 9+ messages in thread
From: Katsumi Yamaoka @ 2010-03-30  4:06 UTC (permalink / raw)
  To: ding

>>>>> Eric Schulte wrote:
>> BTW, have you signed a paper for Gnus or Emacs?

> Yes, I've signed the Emacs papers, and have previously contributed to
> Org-mode, so it should be fine for inclusion.

Installed in Gnus trunk and Emacs trunk.  Thanks!



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

* Re: [PATCH] `gnus-article-browse-html-article' not displaying inline html images
  2010-03-30  4:06           ` Katsumi Yamaoka
@ 2010-03-30 13:36             ` Ted Zlatanov
  2010-03-31  0:12               ` Katsumi Yamaoka
  0 siblings, 1 reply; 9+ messages in thread
From: Ted Zlatanov @ 2010-03-30 13:36 UTC (permalink / raw)
  To: ding

On Tue, 30 Mar 2010 13:06:03 +0900 Katsumi Yamaoka <yamaoka@jpl.org> wrote: 

>>>>>> Eric Schulte wrote:
>>> BTW, have you signed a paper for Gnus or Emacs?

>> Yes, I've signed the Emacs papers, and have previously contributed to
>> Org-mode, so it should be fine for inclusion.

KY> Installed in Gnus trunk and Emacs trunk.  Thanks!

Thank you both for working on this, can you also update the manual?  I
don't think it has anything on cid inline images.

Ted




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

* Re: [PATCH] `gnus-article-browse-html-article' not displaying inline html images
  2010-03-30 13:36             ` Ted Zlatanov
@ 2010-03-31  0:12               ` Katsumi Yamaoka
  0 siblings, 0 replies; 9+ messages in thread
From: Katsumi Yamaoka @ 2010-03-31  0:12 UTC (permalink / raw)
  To: ding

>>>>> Ted Zlatanov wrote:
> Thank you both for working on this, can you also update the manual?  I
> don't think it has anything on cid inline images.

Okay, added.

P.S. I'll fix the code so that the `C-u K H' command may work for
inline images, too.



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

end of thread, other threads:[~2010-03-31  0:12 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-03-26 17:56 BUG: `gnus-article-browse-html-article' not displaying inline html images Eric Schulte
2010-03-27  5:09 ` Ted Zlatanov
2010-03-27 13:26   ` Eric Schulte
2010-03-29 18:15     ` [PATCH] " Eric Schulte
2010-03-30  0:24       ` Katsumi Yamaoka
2010-03-30  1:10         ` Eric Schulte
2010-03-30  4:06           ` Katsumi Yamaoka
2010-03-30 13:36             ` Ted Zlatanov
2010-03-31  0:12               ` Katsumi Yamaoka

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 NNTP newsgroup(s).