aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Ingebrigtsen2019-10-03 16:15:15 +0200
committerLars Ingebrigtsen2019-10-03 16:15:22 +0200
commitcbe3f5f7203b54a7e0ffc65dee83289f1a966077 (patch)
treea50bcee6a981ebb6197a0a50a2f4e0d1723e7ec9
parent0b5fe611e996a609866c3d84ee6c2d1e5dffd812 (diff)
downloademacs-cbe3f5f7203b54a7e0ffc65dee83289f1a966077.tar.gz
emacs-cbe3f5f7203b54a7e0ffc65dee83289f1a966077.zip
Touch up previous shr-dom-to-xml encoding change
* lisp/net/shr.el (shr-dom-to-xml): Include an XML declaration if we're encoding the data. (shr-parse-image-data): Add comment about why encoding is necessary.
-rw-r--r--lisp/net/shr.el9
1 files changed, 7 insertions, 2 deletions
diff --git a/lisp/net/shr.el b/lisp/net/shr.el
index cf32763a4f1..628cc17a5bd 100644
--- a/lisp/net/shr.el
+++ b/lisp/net/shr.el
@@ -1180,7 +1180,9 @@ Return a string with image data."
1180 (eq content-type 'image/svg+xml)) 1180 (eq content-type 'image/svg+xml))
1181 (setq data 1181 (setq data
1182 ;; Note that libxml2 doesn't parse everything perfectly, 1182 ;; Note that libxml2 doesn't parse everything perfectly,
1183 ;; so glitches may occur during this transformation. 1183 ;; so glitches may occur during this transformation. And
1184 ;; encode as utf-8: There may be text (and other elements)
1185 ;; that are non-ASCII.
1184 (shr-dom-to-xml 1186 (shr-dom-to-xml
1185 (libxml-parse-xml-region (point) (point-max)) 'utf-8))) 1187 (libxml-parse-xml-region (point) (point-max)) 'utf-8)))
1186 ;; SVG images often do not have a specified foreground/background 1188 ;; SVG images often do not have a specified foreground/background
@@ -1342,7 +1344,10 @@ ones, in case fg and bg are nil."
1342 (with-temp-buffer 1344 (with-temp-buffer
1343 (shr-dom-print dom) 1345 (shr-dom-print dom)
1344 (when charset 1346 (when charset
1345 (encode-coding-region (point-min) (point-max) charset)) 1347 (encode-coding-region (point-min) (point-max) charset)
1348 (goto-char (point-min))
1349 (insert (format "<?xml version=\"1.0\" encoding=\"%s\"?>\n"
1350 charset)))
1346 (buffer-string))) 1351 (buffer-string)))
1347 1352
1348(defun shr-dom-print (dom) 1353(defun shr-dom-print (dom)