aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorChong Yidong2012-07-03 00:21:54 +0800
committerChong Yidong2012-07-03 00:21:54 +0800
commita7aef6f5c6e22b167ea0234ab84c0308201d681b (patch)
treefd09ca2bd61cdc2e8b8e222b73578c669fa2e354 /test
parent2b5208f18115bd0f364c11cbdc8124878158927a (diff)
downloademacs-a7aef6f5c6e22b167ea0234ab84c0308201d681b.tar.gz
emacs-a7aef6f5c6e22b167ea0234ab84c0308201d681b.zip
* lisp/xml.el: Handle entity and character reference expansion correctly.
(xml-default-ns): New variable. (xml-entity-alist): Use XML spec definitions for lt and amp. (xml-parse-region): Make first two arguments optional. Discard text properties. (xml-parse-tag-1): New function, spun off from xml-parse-tag. All callers changed. (xml-parse-tag): Call xml-parse-tag-1. For backward compatibility, this function should not modify buffer contents. (xml-parse-tag-1): Fix opening-tag regexp. (xml-parse-string): Rewrite, handling entity and character references properly. (xml--entity-replacement-text): Signal an error if a parameter entity is undefined. * test/automated/xml-parse-tests.el (xml-parse-tests--data): More testcases.
Diffstat (limited to 'test')
-rw-r--r--test/ChangeLog5
-rw-r--r--test/automated/xml-parse-tests.el15
2 files changed, 18 insertions, 2 deletions
diff --git a/test/ChangeLog b/test/ChangeLog
index d9d9bc5a9fa..3ff7124893a 100644
--- a/test/ChangeLog
+++ b/test/ChangeLog
@@ -1,3 +1,8 @@
12012-07-02 Chong Yidong <cyd@gnu.org>
2
3 * automated/xml-parse-tests.el (xml-parse-tests--data): More
4 testcases.
5
12012-07-01 Chong Yidong <cyd@gnu.org> 62012-07-01 Chong Yidong <cyd@gnu.org>
2 7
3 * automated/xml-parse-tests.el: New file. 8 * automated/xml-parse-tests.el: New file.
diff --git a/test/automated/xml-parse-tests.el b/test/automated/xml-parse-tests.el
index 8322a8c6ff9..ec3d7ca3065 100644
--- a/test/automated/xml-parse-tests.el
+++ b/test/automated/xml-parse-tests.el
@@ -33,15 +33,26 @@
33 '(;; General entity substitution 33 '(;; General entity substitution
34 ("<?xml version=\"1.0\"?><!DOCTYPE foo SYSTEM \"bar.dtd\" [<!ENTITY ent \"AbC\">]><foo a=\"b\"><bar>&ent;;</bar></foo>" . 34 ("<?xml version=\"1.0\"?><!DOCTYPE foo SYSTEM \"bar.dtd\" [<!ENTITY ent \"AbC\">]><foo a=\"b\"><bar>&ent;;</bar></foo>" .
35 ((foo ((a . "b")) (bar nil "AbC;")))) 35 ((foo ((a . "b")) (bar nil "AbC;"))))
36 ("<?xml version=\"1.0\"?><foo>&amp;amp;&#38;apos;&apos;&lt;&gt;&quot;</foo>" .
37 ((foo () "&amp;&apos;'<>\"")))
36 ;; Parameter entity substitution 38 ;; Parameter entity substitution
37 ("<?xml version=\"1.0\"?><!DOCTYPE foo SYSTEM \"bar.dtd\" [<!ENTITY % pent \"AbC\"><!ENTITY ent \"%pent;\">]><foo a=\"b\"><bar>&ent;;</bar></foo>" . 39 ("<?xml version=\"1.0\"?><!DOCTYPE foo SYSTEM \"bar.dtd\" [<!ENTITY % pent \"AbC\"><!ENTITY ent \"%pent;\">]><foo a=\"b\"><bar>&ent;;</bar></foo>" .
38 ((foo ((a . "b")) (bar nil "AbC;")))) 40 ((foo ((a . "b")) (bar nil "AbC;"))))
39 ;; Tricky parameter entity substitution (like XML spec Appendix D) 41 ;; Tricky parameter entity substitution (like XML spec Appendix D)
40 ("<?xml version='1.0'?><!DOCTYPE foo [ <!ENTITY % xx '&#37;zz;'><!ENTITY % zz '&#60;!ENTITY ent \"b\" >' > %xx; ]><foo>A&ent;C</foo>" . 42 ("<?xml version='1.0'?><!DOCTYPE foo [ <!ENTITY % xx '&#37;zz;'><!ENTITY % zz '&#60;!ENTITY ent \"b\" >' > %xx; ]><foo>A&ent;C</foo>" .
41 ((foo nil "AbC"))) 43 ((foo () "AbC")))
42 ;; Bug#7172 44 ;; Bug#7172
43 ("<?xml version=\"1.0\"?><!DOCTYPE foo [ <!ELEMENT EXAM_PLE EMPTY> ]><foo></foo>" . 45 ("<?xml version=\"1.0\"?><!DOCTYPE foo [ <!ELEMENT EXAM_PLE EMPTY> ]><foo></foo>" .
44 ((foo nil)))) 46 ((foo ())))
47 ;; Entities referencing entities, in character data
48 ("<!DOCTYPE foo [ <!ENTITY b \"B\"><!ENTITY abc \"a&b;c\">]><foo>&abc;</foo>" .
49 ((foo () "aBc")))
50 ;; Entities referencing entities, in attribute values
51 ("<!DOCTYPE foo [ <!ENTITY b \"B\"><!ENTITY abc \"a&b;c\">]><foo a=\"-&abc;-\">1</foo>" .
52 ((foo ((a . "-aBc-")) "1")))
53 ;; Character references must be treated as character data
54 ("<foo>AT&amp;T;</foo>" . ((foo () "AT&T;")))
55 ("<foo>&#38;amp;</foo>" . ((foo () "&amp;"))))
45 "Alist of XML strings and their expected parse trees.") 56 "Alist of XML strings and their expected parse trees.")
46 57
47(ert-deftest xml-parse-tests () 58(ert-deftest xml-parse-tests ()