diff options
| author | Chong Yidong | 2012-08-19 14:37:15 +0800 |
|---|---|---|
| committer | Chong Yidong | 2012-08-19 14:37:15 +0800 |
| commit | 17975d7ff9fd734e67dfb97dc9f8be45fcdaec7c (patch) | |
| tree | 1c1f0a71698006a4a93bd6433ac7b5b3525598db | |
| parent | d7191076ce331e8c78dbc93b76d0e346c268daa0 (diff) | |
| download | emacs-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/ChangeLog | 5 | ||||
| -rw-r--r-- | lisp/xml.el | 26 |
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 @@ | |||
| 1 | 2012-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 | |||
| 1 | 2012-08-18 Chong Yidong <cyd@gnu.org> | 6 | 2012-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) | 1015 | Replace occurrences of &<>'\" in STRING with their default XML |
| 1016 | (let ((char (char-to-string byte))) | 1016 | entity references (e.g. replace each & with &). |
| 1017 | (if (rassoc char xml-entity-alist) | 1017 | |
| 1018 | (concat "&" (car (rassoc char xml-entity-alist)) ";") | 1018 | XML character data must not contain & or < characters, nor the > |
| 1019 | char))) | 1019 | character under some circumstances. The XML spec does not impose |
| 1020 | string "")) | 1020 | restriction 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 '(("&" . "&") | ||
| 1025 | ("<" . "<") | ||
| 1026 | (">" . ">") | ||
| 1027 | ("'" . "'") | ||
| 1028 | ("\"" . """))) | ||
| 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. |