summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorChong Yidong <cyd@gnu.org>2012-07-05 00:14:05 +0800
committerChong Yidong <cyd@gnu.org>2012-07-05 00:14:05 +0800
commit566df3fcac8010303c1d8b8558cb07f3a057b346 (patch)
treec03584ee0936855ce95cb9e84c241cc016c095f5 /test
parent0781098af7c8da77b1d044dce151e6a130eb1e77 (diff)
downloademacs-566df3fcac8010303c1d8b8558cb07f3a057b346.tar.gz
Clean up syntax-table usage in xml.el
* xml.el (xml--parse-buffer): Use xml-syntax-table. (xml-parse-tag): Likewise, and avoid changing entity tables. (xml-syntax-table): Define from scratch, making sure not to give x2000 and other Unicode spaces whitespace syntax, since those are not spaces in XML. (xml-parse-fragment): Delete unused function. (xml-name-start-char-re, xml-name-char-re, xml-name-re) (xml-names-re, xml-nmtoken-re, xml-nmtokens-re, xml-char-ref-re) (xml-entity-ref, xml-pe-reference-re) (xml-reference-re,xml-att-value-re, xml-tokenized-type-re) (xml-notation-type-re, xml-enumeration-re, xml-enumerated-type-re) (xml-att-type-re, xml-default-decl-re, xml-att-def-re) (xml-entity-value-re): Use syntax references in regexps where possible; no need to define inside a let-binding. (xml-parse-dtd): Use xml-pe-reference-re. (xml-entity-or-char-ref-re): New defconst. (xml-parse-string, xml-substitute-special): Use it.
Diffstat (limited to 'test')
-rw-r--r--test/automated/xml-parse-tests.el16
1 files changed, 12 insertions, 4 deletions
diff --git a/test/automated/xml-parse-tests.el b/test/automated/xml-parse-tests.el
index ada9bbd4074..e6553060345 100644
--- a/test/automated/xml-parse-tests.el
+++ b/test/automated/xml-parse-tests.el
@@ -30,10 +30,10 @@
(require 'xml)
(defvar xml-parse-tests--data
- '(;; General entity substitution
+ `(;; General entity substitution
("<?xml version=\"1.0\"?><!DOCTYPE foo SYSTEM \"bar.dtd\" [<!ENTITY ent \"AbC\">]><foo a=\"b\"><bar>&ent;;</bar></foo>" .
((foo ((a . "b")) (bar nil "AbC;"))))
- ("<?xml version=\"1.0\"?><foo>&amp;amp;&#38;apos;&apos;&lt;&gt;&quot;</foo>" .
+ ("<?xml version=\"1.0\"?><foo>&amp;amp;&#x26;apos;&apos;&lt;&gt;&quot;</foo>" .
((foo () "&amp;&apos;'<>\"")))
;; Parameter entity substitution
("<?xml version=\"1.0\"?><!DOCTYPE foo SYSTEM \"bar.dtd\" [<!ENTITY % pent \"AbC\"><!ENTITY ent \"%pent;\">]><foo a=\"b\"><bar>&ent;;</bar></foo>" .
@@ -52,7 +52,11 @@
((foo ((a . "-aBc-")) "1")))
;; Character references must be treated as character data
("<foo>AT&amp;T;</foo>" . ((foo () "AT&T;")))
- ("<foo>&#38;amp;</foo>" . ((foo () "&amp;"))))
+ ("<foo>&#38;amp;</foo>" . ((foo () "&amp;")))
+ ("<foo>&#x26;amp;</foo>" . ((foo () "&amp;")))
+ ;; Unusual but valid XML names [5]
+ ("<ÀÖØö.3·-‿⁀󯿿>abc</ÀÖØö.3·-‿⁀󯿿>" . ((,(intern "ÀÖØö.3·-‿⁀󯿿") () "abc")))
+ ("<:>abc</:>" . ((,(intern ":") () "abc"))))
"Alist of XML strings and their expected parse trees.")
(defvar xml-parse-tests--bad-data
@@ -63,7 +67,11 @@
;; Non-terminating DTD
"<!DOCTYPE foo [ <!ENTITY b \"B\"><!ENTITY abc \"a&b;c\">"
"<!DOCTYPE foo [ <!ENTITY b \"B\"><!ENTITY abc \"a&b;c\">asdf"
- "<!DOCTYPE foo [ <!ENTITY b \"B\"><!ENTITY abc \"a&b;c\">asdf&abc;")
+ "<!DOCTYPE foo [ <!ENTITY b \"B\"><!ENTITY abc \"a&b;c\">asdf&abc;"
+ ;; Invalid XML names
+ "<0foo>abc</0foo>"
+ "<‿foo>abc</‿foo>"
+ "<f¿>abc</f¿>")
"List of XML strings that should signal an error in the parser")
(ert-deftest xml-parse-tests ()