Commit 267c98ae authored by Lars Ingebrigtsen's avatar Lars Ingebrigtsen
Browse files

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).
parent 3180deac
......@@ -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)
(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)))
(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)
(declare-function libxml-parse-xml-region "xml.c"
......@@ -1087,9 +1086,12 @@ Return a string with image data."
;; 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.
(libxml-parse-xml-region (point) (point-max)))))
(list data content-type)))
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment