diff options
author | Lars Ingebrigtsen <larsi@gnus.org> | 2017-01-24 22:21:45 +0100 |
---|---|---|
committer | Lars Ingebrigtsen <larsi@gnus.org> | 2017-01-24 22:21:45 +0100 |
commit | 267c98ae4849e87bcee49ebbb7adcf211c60cd47 (patch) | |
tree | 56cf1cd9d5bd547829fac3534737bb5b159e18c5 /lisp/net/shr.el | |
parent | 3180deacf5562262f8f7b177d1f5f06b8e3ae8a8 (diff) | |
download | emacs-267c98ae4849e87bcee49ebbb7adcf211c60cd47.tar.gz emacs-267c98ae4849e87bcee49ebbb7adcf211c60cd47.tar.bz2 emacs-267c98ae4849e87bcee49ebbb7adcf211c60cd47.zip |
Fix rendering of some complex SVG images
* lisp/net/shr.el (shr-parse-image-data): Don't transform
SVG->DOM->XML unless we're blocking images, as this is apt to
destroy the SVG (bug#24111).
Diffstat (limited to 'lisp/net/shr.el')
-rw-r--r-- | lisp/net/shr.el | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/lisp/net/shr.el b/lisp/net/shr.el index 2ee060611a3..b7c48288494 100644 --- a/lisp/net/shr.el +++ b/lisp/net/shr.el @@ -979,7 +979,7 @@ element is the data blob and the second element is the content-type." (create-image data nil t :ascent 100 :format content-type)) ((eq content-type 'image/svg+xml) - (create-image data 'svg t :ascent 100)) + (create-image data 'imagemagick t :ascent 100)) ((eq size 'full) (ignore-errors (shr-rescale-image data content-type @@ -1067,8 +1067,7 @@ Return a string with image data." (when (ignore-errors (url-cache-extract (url-cache-create-filename (shr-encode-url url))) t) - (when (or (search-forward "\n\n" nil t) - (search-forward "\r\n\r\n" nil t)) + (when (re-search-forward "\r?\n\r?\n" nil t) (shr-parse-image-data))))) (declare-function libxml-parse-xml-region "xml.c" @@ -1087,9 +1086,12 @@ Return a string with image data." 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) + ;; and remove anything that looks like a blocked bit. + (when (and shr-blocked-images + (eq content-type 'image/svg+xml)) (setq data + ;; Note that libxml2 doesn't parse everything perfectly, + ;; so glitches may occur during this transformation. (shr-dom-to-xml (libxml-parse-xml-region (point) (point-max))))) (list data content-type))) |