diff options
| author | Chong Yidong | 2012-07-03 00:21:54 +0800 |
|---|---|---|
| committer | Chong Yidong | 2012-07-03 00:21:54 +0800 |
| commit | a7aef6f5c6e22b167ea0234ab84c0308201d681b (patch) | |
| tree | fd09ca2bd61cdc2e8b8e222b73578c669fa2e354 /test | |
| parent | 2b5208f18115bd0f364c11cbdc8124878158927a (diff) | |
| download | emacs-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/ChangeLog | 5 | ||||
| -rw-r--r-- | test/automated/xml-parse-tests.el | 15 |
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 @@ | |||
| 1 | 2012-07-02 Chong Yidong <cyd@gnu.org> | ||
| 2 | |||
| 3 | * automated/xml-parse-tests.el (xml-parse-tests--data): More | ||
| 4 | testcases. | ||
| 5 | |||
| 1 | 2012-07-01 Chong Yidong <cyd@gnu.org> | 6 | 2012-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;&apos;'<>"</foo>" . | ||
| 37 | ((foo () "&''<>\""))) | ||
| 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 '%zz;'><!ENTITY % zz '<!ENTITY ent \"b\" >' > %xx; ]><foo>A&ent;C</foo>" . | 42 | ("<?xml version='1.0'?><!DOCTYPE foo [ <!ENTITY % xx '%zz;'><!ENTITY % zz '<!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&T;</foo>" . ((foo () "AT&T;"))) | ||
| 55 | ("<foo>&amp;</foo>" . ((foo () "&")))) | ||
| 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 () |