diff options
| author | David Edmondson | 2013-04-16 06:44:35 +0000 |
|---|---|---|
| committer | Katsumi Yamaoka | 2013-04-16 06:44:35 +0000 |
| commit | 2250b3515720da23bc2cd12d597c1a75fac73d46 (patch) | |
| tree | 30a5c472fec74423dbde001ff79a5cc48d22855f | |
| parent | f4ad7ea14b53d7946a71b66adc05c34d87e15a4e (diff) | |
| download | emacs-2250b3515720da23bc2cd12d597c1a75fac73d46.tar.gz emacs-2250b3515720da23bc2cd12d597c1a75fac73d46.zip | |
lisp/gnus/shr.el: Support <img src="data:...">
| -rw-r--r-- | lisp/gnus/ChangeLog | 7 | ||||
| -rw-r--r-- | lisp/gnus/shr.el | 17 |
2 files changed, 24 insertions, 0 deletions
diff --git a/lisp/gnus/ChangeLog b/lisp/gnus/ChangeLog index cc7897accb6..f6cc590b026 100644 --- a/lisp/gnus/ChangeLog +++ b/lisp/gnus/ChangeLog | |||
| @@ -1,3 +1,10 @@ | |||
| 1 | 2013-04-16 David Edmondson <dme@dme.org> | ||
| 2 | |||
| 3 | Support <img src="data:...">. | ||
| 4 | |||
| 5 | * shr.el (shr-image-from-data): New function. | ||
| 6 | (shr-tag-img) Use it. | ||
| 7 | |||
| 1 | 2013-04-14 Andrew Cohen <cohen@bu.edu> | 8 | 2013-04-14 Andrew Cohen <cohen@bu.edu> |
| 2 | 9 | ||
| 3 | * nnir.el (nnir-request-set-mark): Make sure we are in the right | 10 | * nnir.el (nnir-request-set-mark): Make sure we are in the right |
diff --git a/lisp/gnus/shr.el b/lisp/gnus/shr.el index 5df5297ba8a..293ba2445e9 100644 --- a/lisp/gnus/shr.el +++ b/lisp/gnus/shr.el | |||
| @@ -593,6 +593,17 @@ size, and full-buffer size." | |||
| 593 | (put-text-property start (point) type value)))))))))) | 593 | (put-text-property start (point) type value)))))))))) |
| 594 | (kill-buffer image-buffer))) | 594 | (kill-buffer image-buffer))) |
| 595 | 595 | ||
| 596 | (defun shr-image-from-data (data) | ||
| 597 | "Return an image from the data: URI content DATA." | ||
| 598 | (when (string-match | ||
| 599 | "\\(\\([^/;,]+\\(/[^;,]+\\)?\\)\\(;[^;,]+\\)*\\)?,\\(.*\\)" | ||
| 600 | data) | ||
| 601 | (let ((param (match-string 4 data)) | ||
| 602 | (payload (url-unhex-string (match-string 5 data)))) | ||
| 603 | (when (string-match "^.*\\(;[ \t]*base64\\)$" param) | ||
| 604 | (setq payload (base64-decode-string payload))) | ||
| 605 | payload))) | ||
| 606 | |||
| 596 | (defun shr-put-image (data alt &optional flags) | 607 | (defun shr-put-image (data alt &optional flags) |
| 597 | "Put image DATA with a string ALT. Return image." | 608 | "Put image DATA with a string ALT. Return image." |
| 598 | (if (display-graphic-p) | 609 | (if (display-graphic-p) |
| @@ -983,6 +994,12 @@ ones, in case fg and bg are nil." | |||
| 983 | ;; Ignore zero-sized or single-pixel images. | 994 | ;; Ignore zero-sized or single-pixel images. |
| 984 | ) | 995 | ) |
| 985 | ((and (not shr-inhibit-images) | 996 | ((and (not shr-inhibit-images) |
| 997 | (string-match "\\`data:" url)) | ||
| 998 | (let ((image (shr-image-from-data (substring url (match-end 0))))) | ||
| 999 | (if image | ||
| 1000 | (funcall shr-put-image-function image alt) | ||
| 1001 | (insert alt)))) | ||
| 1002 | ((and (not shr-inhibit-images) | ||
| 986 | (string-match "\\`cid:" url)) | 1003 | (string-match "\\`cid:" url)) |
| 987 | (let ((url (substring url (match-end 0))) | 1004 | (let ((url (substring url (match-end 0))) |
| 988 | image) | 1005 | image) |