diff options
| author | Philipp Stephani | 2020-05-23 13:56:09 +0200 |
|---|---|---|
| committer | Philipp Stephani | 2020-05-23 14:01:17 +0200 |
| commit | f8581bcf6a1942ebd331cae20e32945a3a86a3d1 (patch) | |
| tree | 3f1a946cba9cdac5b03f09ec1b01be962256295f /test | |
| parent | 232bb691c1095574b85b358c7f33a46d2ea79f29 (diff) | |
| download | emacs-f8581bcf6a1942ebd331cae20e32945a3a86a3d1.tar.gz emacs-f8581bcf6a1942ebd331cae20e32945a3a86a3d1.zip | |
Reject invalid characters in XML strings (Bug#41094).
* lisp/xml.el (xml-escape-string): Search for invalid characters.
(xml-invalid-character): New error symbol.
* test/lisp/xml-tests.el (xml-print-invalid-cdata): New unit test.
* etc/NEWS: Document new behavior.
Diffstat (limited to 'test')
| -rw-r--r-- | test/lisp/xml-tests.el | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/test/lisp/xml-tests.el b/test/lisp/xml-tests.el index 57e685cd347..72c78d00e3e 100644 --- a/test/lisp/xml-tests.el +++ b/test/lisp/xml-tests.el | |||
| @@ -164,6 +164,16 @@ Parser is called with and without 'symbol-qnames argument.") | |||
| 164 | (should (equal (cdr xml-parse-test--namespace-attribute-qnames) | 164 | (should (equal (cdr xml-parse-test--namespace-attribute-qnames) |
| 165 | (xml-parse-region nil nil nil nil 'symbol-qnames))))) | 165 | (xml-parse-region nil nil nil nil 'symbol-qnames))))) |
| 166 | 166 | ||
| 167 | (ert-deftest xml-print-invalid-cdata () | ||
| 168 | "Check that Bug#41094 is fixed." | ||
| 169 | (with-temp-buffer | ||
| 170 | (should (equal (should-error (xml-print '((foo () "\0"))) | ||
| 171 | :type 'xml-invalid-character) | ||
| 172 | '(xml-invalid-character 0 1))) | ||
| 173 | (should (equal (should-error (xml-print '((foo () "\u00FF \xFF"))) | ||
| 174 | :type 'xml-invalid-character) | ||
| 175 | '(xml-invalid-character #x3FFFFF 3))))) | ||
| 176 | |||
| 167 | ;; Local Variables: | 177 | ;; Local Variables: |
| 168 | ;; no-byte-compile: t | 178 | ;; no-byte-compile: t |
| 169 | ;; End: | 179 | ;; End: |