diff options
| author | Chong Yidong | 2012-07-01 19:05:17 +0800 |
|---|---|---|
| committer | Chong Yidong | 2012-07-01 19:05:17 +0800 |
| commit | 6fe566a75256cd943ad89243021e4e9c041807e2 (patch) | |
| tree | 62fc8a3b28e134328c0034e797f335ae4e036d27 | |
| parent | 7c603e3ed3f137d906506d2f8abeb39d39adb285 (diff) | |
| download | emacs-6fe566a75256cd943ad89243021e4e9c041807e2.tar.gz emacs-6fe566a75256cd943ad89243021e4e9c041807e2.zip | |
* xml.el (xml-parse-dtd): Use proper regexps for ELEMENT declarations.
* test/automated/xml-parse-tests.el: Update testcase.
Fixes: debbugs:7172
| -rw-r--r-- | lisp/ChangeLog | 1 | ||||
| -rw-r--r-- | lisp/xml.el | 15 | ||||
| -rw-r--r-- | test/automated/xml-parse-tests.el | 5 |
3 files changed, 14 insertions, 7 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 3156dc412e3..d6ad29309e7 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -7,6 +7,7 @@ | |||
| 7 | Use xml--parse-buffer. | 7 | Use xml--parse-buffer. |
| 8 | (xml-parse-file): Use xml--parse-buffer. | 8 | (xml-parse-file): Use xml--parse-buffer. |
| 9 | (xml-parse-dtd): Make parameter entity substitution work right. | 9 | (xml-parse-dtd): Make parameter entity substitution work right. |
| 10 | Use proper regexps for ELEMENT declarations (Bug#7172). | ||
| 10 | 11 | ||
| 11 | 2012-06-30 Glenn Morris <rgm@gnu.org> | 12 | 2012-06-30 Glenn Morris <rgm@gnu.org> |
| 12 | 13 | ||
diff --git a/lisp/xml.el b/lisp/xml.el index 841e19a174a..5c1d2390a23 100644 --- a/lisp/xml.el +++ b/lisp/xml.el | |||
| @@ -651,7 +651,9 @@ This follows the rule [28] in the XML specifications." | |||
| 651 | (skip-syntax-forward " ") | 651 | (skip-syntax-forward " ") |
| 652 | (cond | 652 | (cond |
| 653 | ;; Element declaration [45]: | 653 | ;; Element declaration [45]: |
| 654 | ((and (looking-at "<!ELEMENT\\s-+\\([[:alnum:].%;]+\\)\\s-+\\([^>]+\\)>") | 654 | ((and (looking-at (eval-when-compile |
| 655 | (concat "<!ELEMENT\\s-+\\(" xml-name-re | ||
| 656 | "\\)\\s-+\\([^>]+\\)>"))) | ||
| 655 | (or (null next-parameter-entity) | 657 | (or (null next-parameter-entity) |
| 656 | (<= (match-end 0) next-parameter-entity))) | 658 | (<= (match-end 0) next-parameter-entity))) |
| 657 | (let ((element (match-string-no-properties 1)) | 659 | (let ((element (match-string-no-properties 1)) |
| @@ -659,13 +661,14 @@ This follows the rule [28] in the XML specifications." | |||
| 659 | (end-pos (match-end 0))) | 661 | (end-pos (match-end 0))) |
| 660 | ;; Translation of rule [46] of XML specifications | 662 | ;; Translation of rule [46] of XML specifications |
| 661 | (cond | 663 | (cond |
| 662 | ((string-match "^EMPTY[ \t\n\r]*$" type) ; empty declaration | 664 | ((string-match "\\`EMPTY\\s-*\\'" type) ; empty declaration |
| 663 | (setq type 'empty)) | 665 | (setq type 'empty)) |
| 664 | ((string-match "^ANY[ \t\n\r]*$" type) ; any type of contents | 666 | ((string-match "\\`ANY\\s-*$" type) ; any type of contents |
| 665 | (setq type 'any)) | 667 | (setq type 'any)) |
| 666 | ((string-match "^(\\(.*\\))[ \t\n\r]*$" type) ; children ([47]) | 668 | ((string-match "\\`(\\(.*\\))\\s-*\\'" type) ; children ([47]) |
| 667 | (setq type (xml-parse-elem-type (match-string-no-properties 1 type)))) | 669 | (setq type (xml-parse-elem-type |
| 668 | ((string-match "^%[^;]+;[ \t\n\r]*$" type) ; substitution | 670 | (match-string-no-properties 1 type)))) |
| 671 | ((string-match "^%[^;]+;[ \t\n\r]*\\'" type) ; substitution | ||
| 669 | nil) | 672 | nil) |
| 670 | (xml-validating-parser | 673 | (xml-validating-parser |
| 671 | (error "XML: (Validity) Invalid element type in the DTD"))) | 674 | (error "XML: (Validity) Invalid element type in the DTD"))) |
diff --git a/test/automated/xml-parse-tests.el b/test/automated/xml-parse-tests.el index 8e8ef291bdc..8322a8c6ff9 100644 --- a/test/automated/xml-parse-tests.el +++ b/test/automated/xml-parse-tests.el | |||
| @@ -38,7 +38,10 @@ | |||
| 38 | ((foo ((a . "b")) (bar nil "AbC;")))) | 38 | ((foo ((a . "b")) (bar nil "AbC;")))) |
| 39 | ;; Tricky parameter entity substitution (like XML spec Appendix D) | 39 | ;; 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>" . | 40 | ("<?xml version='1.0'?><!DOCTYPE foo [ <!ENTITY % xx '%zz;'><!ENTITY % zz '<!ENTITY ent \"b\" >' > %xx; ]><foo>A&ent;C</foo>" . |
| 41 | ((foo nil "AbC")))) | 41 | ((foo nil "AbC"))) |
| 42 | ;; Bug#7172 | ||
| 43 | ("<?xml version=\"1.0\"?><!DOCTYPE foo [ <!ELEMENT EXAM_PLE EMPTY> ]><foo></foo>" . | ||
| 44 | ((foo nil)))) | ||
| 42 | "Alist of XML strings and their expected parse trees.") | 45 | "Alist of XML strings and their expected parse trees.") |
| 43 | 46 | ||
| 44 | (ert-deftest xml-parse-tests () | 47 | (ert-deftest xml-parse-tests () |