diff options
| author | Lars Ingebrigtsen | 2017-01-24 22:21:45 +0100 |
|---|---|---|
| committer | Lars Ingebrigtsen | 2017-01-24 22:21:45 +0100 |
| commit | 267c98ae4849e87bcee49ebbb7adcf211c60cd47 (patch) | |
| tree | 56cf1cd9d5bd547829fac3534737bb5b159e18c5 | |
| parent | 3180deacf5562262f8f7b177d1f5f06b8e3ae8a8 (diff) | |
| download | emacs-267c98ae4849e87bcee49ebbb7adcf211c60cd47.tar.gz 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).
| -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." | |||
| 979 | (create-image data nil t :ascent 100 | 979 | (create-image data nil t :ascent 100 |
| 980 | :format content-type)) | 980 | :format content-type)) |
| 981 | ((eq content-type 'image/svg+xml) | 981 | ((eq content-type 'image/svg+xml) |
| 982 | (create-image data 'svg t :ascent 100)) | 982 | (create-image data 'imagemagick t :ascent 100)) |
| 983 | ((eq size 'full) | 983 | ((eq size 'full) |
| 984 | (ignore-errors | 984 | (ignore-errors |
| 985 | (shr-rescale-image data content-type | 985 | (shr-rescale-image data content-type |
| @@ -1067,8 +1067,7 @@ Return a string with image data." | |||
| 1067 | (when (ignore-errors | 1067 | (when (ignore-errors |
| 1068 | (url-cache-extract (url-cache-create-filename (shr-encode-url url))) | 1068 | (url-cache-extract (url-cache-create-filename (shr-encode-url url))) |
| 1069 | t) | 1069 | t) |
| 1070 | (when (or (search-forward "\n\n" nil t) | 1070 | (when (re-search-forward "\r?\n\r?\n" nil t) |
| 1071 | (search-forward "\r\n\r\n" nil t)) | ||
| 1072 | (shr-parse-image-data))))) | 1071 | (shr-parse-image-data))))) |
| 1073 | 1072 | ||
| 1074 | (declare-function libxml-parse-xml-region "xml.c" | 1073 | (declare-function libxml-parse-xml-region "xml.c" |
| @@ -1087,9 +1086,12 @@ Return a string with image data." | |||
| 1087 | obarray))))))) | 1086 | obarray))))))) |
| 1088 | ;; SVG images may contain references to further images that we may | 1087 | ;; SVG images may contain references to further images that we may |
| 1089 | ;; want to block. So special-case these by parsing the XML data | 1088 | ;; want to block. So special-case these by parsing the XML data |
| 1090 | ;; and remove the blocked bits. | 1089 | ;; and remove anything that looks like a blocked bit. |
| 1091 | (when (eq content-type 'image/svg+xml) | 1090 | (when (and shr-blocked-images |
| 1091 | (eq content-type 'image/svg+xml)) | ||
| 1092 | (setq data | 1092 | (setq data |
| 1093 | ;; Note that libxml2 doesn't parse everything perfectly, | ||
| 1094 | ;; so glitches may occur during this transformation. | ||
| 1093 | (shr-dom-to-xml | 1095 | (shr-dom-to-xml |
| 1094 | (libxml-parse-xml-region (point) (point-max))))) | 1096 | (libxml-parse-xml-region (point) (point-max))))) |
| 1095 | (list data content-type))) | 1097 | (list data content-type))) |