Fixes: debbugs:16244
* net/eww.el (eww-form-file): Fix version number.
* net/shr.el (shr-parse-image-data): Remove blocked bits from
external SVG images.
(shr-tag-object): Display images in <object> forms.
(shr-tag-table): Also insert <objects> after the tables.
(let ((buf (get-buffer-create "*eww-source*"))
(source (plist-get eww-data :source)))
(with-current-buffer buf
(let ((buf (get-buffer-create "*eww-source*"))
(source (plist-get eww-data :source)))
(with-current-buffer buf
- (delete-region (point-min) (point-max))
- (insert (or source "no source"))
- (goto-char (point-min))
- (when (fboundp 'html-mode)
- (html-mode)))
+ (let ((inhibit-read-only t))
+ (delete-region (point-min) (point-max))
+ (insert (or source "no source"))
+ (goto-char (point-min))
+ (when (fboundp 'html-mode)
+ (html-mode))))
(view-buffer buf)))
(defun eww-readable ()
(view-buffer buf)))
(defun eww-readable ()
((eq size 'original)
(create-image data nil t :ascent 100
:format content-type))
((eq size 'original)
(create-image data nil t :ascent 100
:format content-type))
+ ((eq content-type 'image/svg+xml)
+ (create-image data 'svg t :ascent 100))
((eq size 'full)
(ignore-errors
(shr-rescale-image data content-type)))
((eq size 'full)
(ignore-errors
(shr-rescale-image data content-type)))
(shr-parse-image-data)))))
(defun shr-parse-image-data ()
(shr-parse-image-data)))))
(defun shr-parse-image-data ()
- (list
- (buffer-substring (point) (point-max))
- (save-excursion
- (save-restriction
- (narrow-to-region (point-min) (point))
- (let ((content-type (mail-fetch-field "content-type")))
- (and content-type
- (intern content-type obarray)))))))
+ (let ((data (buffer-substring (point) (point-max)))
+ (content-type
+ (save-excursion
+ (save-restriction
+ (narrow-to-region (point-min) (point))
+ (let ((content-type (mail-fetch-field "content-type")))
+ (and content-type
+ ;; Remove any comments in the type string.
+ (intern (replace-regexp-in-string ";.*" "" content-type)
+ obarray)))))))
+ ;; SVG images may contain references to further images that we may
+ ;; want to block. So special-case these by parsing the XML data
+ ;; and remove the blocked bits.
+ (when (eq content-type 'image/svg+xml)
+ (setq data
+ (shr-dom-to-xml
+ (shr-transform-dom
+ (libxml-parse-xml-region (point) (point-max))))))
+ (list data content-type)))
(defun shr-image-displayer (content-function)
"Return a function to display an image.
(defun shr-image-displayer (content-function)
"Return a function to display an image.
(shr-urlify (or shr-start start) (shr-expand-url url) title))))
(defun shr-tag-object (cont)
(shr-urlify (or shr-start start) (shr-expand-url url) title))))
(defun shr-tag-object (cont)
- (let ((start (point))
- url)
- (dolist (elem cont)
- (when (eq (car elem) 'embed)
- (setq url (or url (cdr (assq :src (cdr elem))))))
- (when (and (eq (car elem) 'param)
- (equal (cdr (assq :name (cdr elem))) "movie"))
- (setq url (or url (cdr (assq :value (cdr elem)))))))
- (when url
- (shr-insert " [multimedia] ")
- (shr-urlify start (shr-expand-url url)))
- (shr-generic cont)))
+ (unless shr-inhibit-images
+ (let ((start (point))
+ url multimedia image)
+ (dolist (elem cont)
+ (cond
+ ((eq (car elem) 'embed)
+ (setq url (or url (cdr (assq :src (cdr elem))))
+ multimedia t))
+ ((and (eq (car elem) 'param)
+ (equal (cdr (assq :name (cdr elem))) "movie"))
+ (setq url (or url (cdr (assq :value (cdr elem))))
+ multimedia t))
+ ((and (eq (car elem) :type)
+ (string-match "\\`image/svg" (cdr elem)))
+ (setq url (cdr (assq :data cont))
+ image t))))
+ (when url
+ (cond
+ (image
+ (shr-tag-img cont url)
+ (setq cont nil))
+ (multimedia
+ (shr-insert " [multimedia] ")
+ (shr-urlify start (shr-expand-url url)))))
+ (when cont
+ (shr-generic cont)))))
(defcustom shr-prefer-media-type-alist '(("webm" . 1.0)
("ogv" . 1.0)
(defcustom shr-prefer-media-type-alist '(("webm" . 1.0)
("ogv" . 1.0)
;; model isn't strong enough to allow us to put the images actually
;; into the tables.
(when (zerop shr-table-depth)
;; model isn't strong enough to allow us to put the images actually
;; into the tables.
(when (zerop shr-table-depth)
+ (dolist (elem (shr-find-elements cont 'object))
+ (shr-tag-object (cdr elem)))
(dolist (elem (shr-find-elements cont 'img))
(shr-tag-img (cdr elem))))))
(dolist (elem (shr-find-elements cont 'img))
(shr-tag-img (cdr elem))))))