aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChong Yidong2012-08-19 14:37:15 +0800
committerChong Yidong2012-08-19 14:37:15 +0800
commit17975d7ff9fd734e67dfb97dc9f8be45fcdaec7c (patch)
tree1c1f0a71698006a4a93bd6433ac7b5b3525598db
parentd7191076ce331e8c78dbc93b76d0e346c268daa0 (diff)
downloademacs-17975d7ff9fd734e67dfb97dc9f8be45fcdaec7c.tar.gz
emacs-17975d7ff9fd734e67dfb97dc9f8be45fcdaec7c.zip
* xml.el (xml-escape-string): Don't refer to xml-entity-alist.
Fixes: debbugs:12228
-rw-r--r--lisp/ChangeLog5
-rw-r--r--lisp/xml.el26
2 files changed, 24 insertions, 7 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index ec89b3784d9..17c7fa0f06a 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,8 @@
12012-08-19 Chong Yidong <cyd@gnu.org>
2
3 * xml.el (xml-escape-string): Don't refer to xml-entity-alist
4 (Bug#12228).
5
12012-08-18 Chong Yidong <cyd@gnu.org> 62012-08-18 Chong Yidong <cyd@gnu.org>
2 7
3 * simple.el (yank-handled-properties): New defcustom. 8 * simple.el (yank-handled-properties): New defcustom.
diff --git a/lisp/xml.el b/lisp/xml.el
index 179fdd6b5cc..d395f75ec0f 100644
--- a/lisp/xml.el
+++ b/lisp/xml.el
@@ -1011,13 +1011,25 @@ The first line is indented with the optional INDENT-STRING."
1011(defalias 'xml-print 'xml-debug-print) 1011(defalias 'xml-print 'xml-debug-print)
1012 1012
1013(defun xml-escape-string (string) 1013(defun xml-escape-string (string)
1014 "Return STRING with entity substitutions made from `xml-entity-alist'." 1014 "Convert STRING into a string containing valid XML character data.
1015 (mapconcat (lambda (byte) 1015Replace occurrences of &<>'\" in STRING with their default XML
1016 (let ((char (char-to-string byte))) 1016entity references (e.g. replace each & with &amp;).
1017 (if (rassoc char xml-entity-alist) 1017
1018 (concat "&" (car (rassoc char xml-entity-alist)) ";") 1018XML character data must not contain & or < characters, nor the >
1019 char))) 1019character under some circumstances. The XML spec does not impose
1020 string "")) 1020restriction on \" or ', but we just substitute for these too
1021\(as is permitted by the spec)."
1022 (with-temp-buffer
1023 (insert string)
1024 (dolist (substitution '(("&" . "&amp;")
1025 ("<" . "&lt;")
1026 (">" . "&gt;")
1027 ("'" . "&apos;")
1028 ("\"" . "&quot;")))
1029 (goto-char (point-min))
1030 (while (search-forward (car substitution) nil t)
1031 (replace-match (cdr substitution) t t nil)))
1032 (buffer-string)))
1021 1033
1022(defun xml-debug-print-internal (xml indent-string) 1034(defun xml-debug-print-internal (xml indent-string)
1023 "Outputs the XML tree in the current buffer. 1035 "Outputs the XML tree in the current buffer.