Use gnus-html-encode-url to encode URL
authorJulien Danjou <julien@danjou.info>
Wed, 22 Sep 2010 13:40:49 +0000 (15:40 +0200)
committerJulien Danjou <julien@danjou.info>
Wed, 22 Sep 2010 14:36:02 +0000 (16:36 +0200)
Signed-off-by: Julien Danjou <julien@danjou.info>
lisp/ChangeLog
lisp/gnus-html.el

index 54a1ff8..87c5dec 100644 (file)
@@ -6,6 +6,10 @@
 
        * gnus-html.el (gnus-html-get-image-data): Search also for \r\n\r\n to
        get the start of data.
+       (gnus-html-encode-url): Add this function to encode special chars in
+       URL.
+       (gnus-html-wash-images): Use gnus-html-encode-url to encode URL.
+       (gnus-html-prefetch-images): Use gnus-html-encode-url to encode URL.
 
        * gnus-group.el (gnus-group-update-hook): Call gnus-group-add-icon by
        default.
index 847a3d1..d91db08 100644 (file)
@@ -36,6 +36,7 @@
 (require 'url)
 (require 'url-cache)
 (require 'xml)
+(require 'browse-url)
 
 (defcustom gnus-html-image-cache-ttl (days-to-time 7)
   "Time in seconds used to cache the image on disk."
@@ -81,6 +82,10 @@ fit these criteria."
     (define-key map [tab] 'widget-forward)
     map))
 
+(defun gnus-html-encode-url (url)
+  "Encode URL."
+  (browse-url-url-encode-chars url "[)$ ]"))
+
 (defun gnus-html-cache-expired (url ttl)
   "Check if URL is cached for more than TTL."
   (cond (url-standalone-mode
@@ -155,7 +160,7 @@ fit these criteria."
        (delete-region (match-beginning 0) (match-end 0)))
       (setq end (point))
       (when (string-match "src=\"\\([^\"]+\\)" parameters)
-       (setq url (match-string 1 parameters))
+       (setq url (gnus-html-encode-url (match-string 1 parameters)))
        (gnus-message 8 "gnus-html-wash-tags: fetching image URL %s" url)
        (if (string-match "^cid:\\(.*\\)" url)
            ;; URLs with cid: have their content stashed in other
@@ -473,7 +478,7 @@ This only works if the article in question is HTML."
                             gnus-blocked-images)))
       (save-match-data
        (while (re-search-forward "<img.*src=[\"']\\([^\"']+\\)" nil t)
-         (let ((url (match-string 1)))
+         (let ((url (gnus-html-encode-url (match-string 1))))
            (unless (gnus-html-image-url-blocked-p url blocked-images)
               (when (gnus-html-cache-expired url gnus-html-image-cache-ttl)
                 (gnus-html-schedule-image-fetching nil