diff options
author | Chong Yidong <cyd@gnu.org> | 2012-07-05 00:14:05 +0800 |
---|---|---|
committer | Chong Yidong <cyd@gnu.org> | 2012-07-05 00:14:05 +0800 |
commit | 566df3fcac8010303c1d8b8558cb07f3a057b346 (patch) | |
tree | c03584ee0936855ce95cb9e84c241cc016c095f5 /test | |
parent | 0781098af7c8da77b1d044dce151e6a130eb1e77 (diff) | |
download | emacs-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.el | 16 |
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;&apos;'<>"</foo>" . + ("<?xml version=\"1.0\"?><foo>&amp;&apos;'<>"</foo>" . ((foo () "&''<>\""))) ;; 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&T;</foo>" . ((foo () "AT&T;"))) - ("<foo>&amp;</foo>" . ((foo () "&")))) + ("<foo>&amp;</foo>" . ((foo () "&"))) + ("<foo>&amp;</foo>" . ((foo () "&"))) + ;; 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 () |