Gnus development mailing list
 help / color / mirror / Atom feed
* [emacs-w3m:11116] Content-Location ignored?
@ 2010-01-25  5:54 jidanni
  2010-01-26  8:51 ` [emacs-w3m:11119] " Katsumi Yamaoka
  0 siblings, 1 reply; 6+ messages in thread
From: jidanni @ 2010-01-25  5:54 UTC (permalink / raw)
  To: ding; +Cc: emacs-w3m

I notice that even though images in multipart messages contain

  Content-Type: image/gif
  Content-Transfer-Encoding: base64
  Content-Location: http://www.ihaoke.com/html/blogpic/blog_pic_120601.gif

gnus and/or w3m attempt to get them from the network, instead of using
the images from within the message. See RFC 2616 part 14.14
Content-Location, perhaps.
Sample mail message: http://filebin.ca/ctvtmc/ihaoke-Content-Location-example.txt.bz2
My configuration: http://jidanni.org/comp/configuration/ .

The idea is that if <IMG src=> matches any Content-Locations in the same
message, it can then use those matching images, instead of needing to go
to the real location.

There I was reading offline, and unable to have the images appear where
they belong in the message.



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

* [emacs-w3m:11119] Re: Content-Location ignored?
  2010-01-25  5:54 [emacs-w3m:11116] Content-Location ignored? jidanni
@ 2010-01-26  8:51 ` Katsumi Yamaoka
  2010-04-17 20:15   ` [emacs-w3m:11210] " jidanni
  2010-04-18  0:01   ` [emacs-w3m:11119] " Kevin Ryde
  0 siblings, 2 replies; 6+ messages in thread
From: Katsumi Yamaoka @ 2010-01-26  8:51 UTC (permalink / raw)
  To: ding; +Cc: emacs-w3m

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

>>>>> In [emacs-w3m : No.11116] jidanni@jidanni.org wrote:
> I notice that even though images in multipart messages contain

>   Content-Type: image/gif
>   Content-Transfer-Encoding: base64
>   Content-Location: http://www.ihaoke.com/html/blogpic/blog_pic_120601.gif

> gnus and/or w3m attempt to get them from the network, instead of using
> the images from within the message. See RFC 2616 part 14.14
> Content-Location, perhaps.
> Sample mail message: http://filebin.ca/ctvtmc/ihaoke-Content-Location-example.txt.bz2
> My configuration: http://jidanni.org/comp/configuration/ .

> The idea is that if <IMG src=> matches any Content-Locations in the same
> message, it can then use those matching images, instead of needing to go
> to the real location.

> There I was reading offline, and unable to have the images appear where
> they belong in the message.

So far I have no proper way for that.  A dirty hack:


[-- Attachment #2: Type: application/emacs-lisp, Size: 1069 bytes --]

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

* [emacs-w3m:11210] Re: Content-Location ignored?
  2010-01-26  8:51 ` [emacs-w3m:11119] " Katsumi Yamaoka
@ 2010-04-17 20:15   ` jidanni
  2010-04-18  0:01   ` [emacs-w3m:11119] " Kevin Ryde
  1 sibling, 0 replies; 6+ messages in thread
From: jidanni @ 2010-04-17 20:15 UTC (permalink / raw)
  To: emacs-w3m; +Cc: ding

>>>>> "KY" == Katsumi Yamaoka <yamaoka@jpl.org> writes:
>>>>> In [emacs-w3m : No.11116] jidanni@jidanni.org wrote:
>> I notice that even though images in multipart messages contain
>> Content-Location: http://www.ihaoke.com/html/blogpic/blog_pic_120601.gif
>> gnus and/or w3m attempt to get them from the network, instead of using
>> the images from within the message. See RFC 2616 part 14.14
>> Content-Location, perhaps.

KY> So far I have no proper way for that.  A dirty hack:
KY> (defadvice mm-dissect-buffer (before replace-content-location-with-content-id...
I added http://filebin.ca/pqtea/haoke201004 as a second example message
if anybody is interested in working on a permanent solution.



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

* Re: [emacs-w3m:11119] Re: Content-Location ignored?
  2010-01-26  8:51 ` [emacs-w3m:11119] " Katsumi Yamaoka
  2010-04-17 20:15   ` [emacs-w3m:11210] " jidanni
@ 2010-04-18  0:01   ` Kevin Ryde
  2010-04-19  8:16     ` Katsumi Yamaoka
  1 sibling, 1 reply; 6+ messages in thread
From: Kevin Ryde @ 2010-04-18  0:01 UTC (permalink / raw)
  To: ding

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

I had a go a while back at picking out the content-location from parts,
per below.  It might have bit-rotted by now.  Apologies if I already
reposted this and forgot.

It was aimed the other way, to get the content-location on a html part
through to w3m so it can resolve relative urls to the right place.  But
if the content-location is of interest for other things it might be
worth holding in the mm-handle irrespective whether that resolving is
done yet.

Is it possible to give w3m a temporary cache of the provided parts and
their urls?  That'd sound easier than re-writing to content ids.



[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: mm-decode.el.content-location.diff --]
[-- Type: text/x-diff, Size: 4098 bytes --]

--- mm-decode.el	04 Nov 2008 10:27:16 +1100	7.68
+++ mm-decode.el	04 Nov 2008 10:27:23 +1100	
@@ -89,6 +89,8 @@
   `(setcar (nthcdr 6 ,handle) ,contents))
 (defmacro mm-handle-id (handle)
   `(nth 7 ,handle))
+(defmacro mm-handle-content-location (handle)
+  `(nth 8 ,handle))
 (defmacro mm-handle-multipart-original-buffer (handle)
   `(get-text-property 0 'buffer (car ,handle)))
 (defmacro mm-handle-multipart-from (handle)
@@ -98,9 +100,9 @@
 
 (defmacro mm-make-handle (&optional buffer type encoding undisplayer
 				    disposition description cache
-				    id)
+				    id content-location)
   `(list ,buffer ,type ,encoding ,undisplayer
-	 ,disposition ,description ,cache ,id))
+	 ,disposition ,description ,cache ,id ,content-location))
 
 (defcustom mm-text-html-renderer
   (cond ((executable-find "w3m")
@@ -550,7 +552,7 @@
     (message "Destroying external MIME viewers")
     (mm-destroy-parts mm-postponed-undisplay-list)))
 
-(defun mm-dissect-buffer (&optional no-strict-mime loose-mime from)
+(defun mm-dissect-buffer (&optional no-strict-mime loose-mime from content-location)
   "Dissect the current buffer and return a list of MIME handles."
   (save-excursion
     (let (ct ctl type subtype cte cd description id result)
@@ -564,7 +566,9 @@
 		cte (mail-fetch-field "content-transfer-encoding")
 		cd (mail-fetch-field "content-disposition")
 		description (mail-fetch-field "content-description")
-		id (mail-fetch-field "content-id"))
+		id (mail-fetch-field "content-id")
+		content-location (or (mail-fetch-field "content-location")
+                                     content-location))
 	  (unless from
 	    (setq from (mail-fetch-field "from")))
 	  ;; FIXME: In some circumstances, this code is running within
@@ -583,7 +587,7 @@
 	   (and cte (intern (downcase (mail-header-strip cte))))
 	   no-strict-mime
 	   (and cd (mail-header-parse-content-disposition cd))
-	   description)
+	   description content-location)
 	(setq type (split-string (car ctl) "/"))
 	(setq subtype (cadr type)
 	      type (car type))
@@ -608,7 +612,7 @@
 					'from from
 					'start start)
 				  (car ctl))
-	     (cons (car ctl) (mm-dissect-multipart ctl from))))
+	     (cons (car ctl) (mm-dissect-multipart ctl from content-location))))
 	  (t
 	   (mm-possibly-verify-or-decrypt
 	    (mm-dissect-singlepart
@@ -616,7 +620,7 @@
 	     (and cte (intern (downcase (mail-header-strip cte))))
 	     no-strict-mime
 	     (and cd (mail-header-parse-content-disposition cd))
-	     description id)
+	     description id content-location)
 	    ctl))))
 	(when id
 	  (when (string-match " *<\\(.*\\)> *" id)
@@ -624,15 +628,15 @@
 	  (push (cons id result) mm-content-id-alist))
 	result))))
 
-(defun mm-dissect-singlepart (ctl cte &optional force cdl description id)
+(defun mm-dissect-singlepart (ctl cte &optional force cdl description id content-location)
   (when (or force
 	    (if (equal "text/plain" (car ctl))
 		(assoc 'format ctl)
 	      t))
     (mm-make-handle
-     (mm-copy-to-buffer) ctl cte nil cdl description nil id)))
+     (mm-copy-to-buffer) ctl cte nil cdl description nil id content-location)))
 
-(defun mm-dissect-multipart (ctl from)
+(defun mm-dissect-multipart (ctl from content-location)
   (goto-char (point-min))
   (let* ((boundary (concat "\n--" (mail-content-type-get ctl 'boundary)))
 	 (close-delimiter (concat (regexp-quote boundary) "--[ \t]*$"))
@@ -649,7 +653,7 @@
 	(save-excursion
 	  (save-restriction
 	    (narrow-to-region start (point))
-	    (setq parts (nconc (list (mm-dissect-buffer t nil from)) parts)))))
+	    (setq parts (nconc (list (mm-dissect-buffer t nil from content-location)) parts)))))
       (end-of-line 2)
       (or (looking-at boundary)
 	  (forward-line 1))
@@ -658,7 +662,7 @@
       (save-excursion
 	(save-restriction
 	  (narrow-to-region start end)
-	  (setq parts (nconc (list (mm-dissect-buffer t nil from)) parts)))))
+	  (setq parts (nconc (list (mm-dissect-buffer t nil from content-location)) parts)))))
     (mm-possibly-verify-or-decrypt (nreverse parts) ctl)))
 
 (defun mm-copy-to-buffer ()

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: mm-view.el.content-location.diff --]
[-- Type: text/x-diff, Size: 514 bytes --]

--- mm-view.el	04 Nov 2008 10:26:46 +1100	7.59
+++ mm-view.el	04 Nov 2008 10:26:55 +1100	
@@ -257,7 +257,8 @@
 	    (insert (mm-decode-string text charset))))
 	(let ((w3m-safe-url-regexp mm-w3m-safe-url-regexp)
 	      w3m-force-redisplay)
-	  (w3m-region (point-min) (point-max) nil charset))
+	  (w3m-region (point-min) (point-max)
+                      (mm-handle-content-location handle) charset))
 	(when (and mm-inline-text-html-with-w3m-keymap
 		   (boundp 'w3m-minor-mode-map)
 		   w3m-minor-mode-map)

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

* Re: Content-Location ignored?
  2010-04-18  0:01   ` [emacs-w3m:11119] " Kevin Ryde
@ 2010-04-19  8:16     ` Katsumi Yamaoka
  2010-04-24  1:00       ` Kevin Ryde
  0 siblings, 1 reply; 6+ messages in thread
From: Katsumi Yamaoka @ 2010-04-19  8:16 UTC (permalink / raw)
  To: ding

>>>>> Kevin Ryde wrote:
> I had a go a while back at picking out the content-location from parts,
> per below.  It might have bit-rotted by now.  Apologies if I already
> reposted this and forgot.

> It was aimed the other way, to get the content-location on a html part
> through to w3m so it can resolve relative urls to the right place.  But
> if the content-location is of interest for other things it might be
> worth holding in the mm-handle irrespective whether that resolving is
> done yet.

> Is it possible to give w3m a temporary cache of the provided parts and
> their urls?  That'd sound easier than re-writing to content ids.

So, how does it make Gnus and emacs-w3m use contents embedded in
an article instead of retrieving the remote ones?  I tried your
patch but didn't see it stops the remote access.  OP's articles:
http://article.gmane.org/gmane.emacs.w3m/8475
http://article.gmane.org/gmane.emacs.w3m/8569



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

* Re: Content-Location ignored?
  2010-04-19  8:16     ` Katsumi Yamaoka
@ 2010-04-24  1:00       ` Kevin Ryde
  0 siblings, 0 replies; 6+ messages in thread
From: Kevin Ryde @ 2010-04-24  1:00 UTC (permalink / raw)
  To: ding

Katsumi Yamaoka <yamaoka@jpl.org> writes:
>
> So, how does it make Gnus and emacs-w3m use contents embedded in
> an article instead of retrieving the remote ones?

Yeah, no, like I said, it gets the location through so w3m can do the
right thing on relative links.  If the Content-Location of parts is
wanted for trying to match up parts then it could be worth saving it in
the parsed handle thingie like I made.

Or alternatively save all part-headers instead of treating them one by
one.  I suppose there's only a few that will ever exist or actually
affect anything though.

(I suspect trying to match up multiple parts ad-hoc may be more trouble
than its worth, unless it can be just all thrown to w3m and let it worry
about it.  Does the "mhtml" spec thingie say it's all supposed to come
with Content-ID instead of Content-Location anyway?)



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

end of thread, other threads:[~2010-04-24  1:00 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-01-25  5:54 [emacs-w3m:11116] Content-Location ignored? jidanni
2010-01-26  8:51 ` [emacs-w3m:11119] " Katsumi Yamaoka
2010-04-17 20:15   ` [emacs-w3m:11210] " jidanni
2010-04-18  0:01   ` [emacs-w3m:11119] " Kevin Ryde
2010-04-19  8:16     ` Katsumi Yamaoka
2010-04-24  1:00       ` Kevin Ryde

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).