summaryrefslogtreecommitdiff
path: root/lisp/xml.el
diff options
context:
space:
mode:
authorChong Yidong <cyd@gnu.org>2012-07-01 19:05:17 +0800
committerChong Yidong <cyd@gnu.org>2012-07-01 19:05:17 +0800
commit6fe566a75256cd943ad89243021e4e9c041807e2 (patch)
tree62fc8a3b28e134328c0034e797f335ae4e036d27 /lisp/xml.el
parent7c603e3ed3f137d906506d2f8abeb39d39adb285 (diff)
downloademacs-6fe566a75256cd943ad89243021e4e9c041807e2.tar.gz
* xml.el (xml-parse-dtd): Use proper regexps for ELEMENT declarations.
* test/automated/xml-parse-tests.el: Update testcase. Fixes: debbugs:7172
Diffstat (limited to 'lisp/xml.el')
-rw-r--r--lisp/xml.el15
1 files changed, 9 insertions, 6 deletions
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."
(skip-syntax-forward " ")
(cond
;; Element declaration [45]:
- ((and (looking-at "<!ELEMENT\\s-+\\([[:alnum:].%;]+\\)\\s-+\\([^>]+\\)>")
+ ((and (looking-at (eval-when-compile
+ (concat "<!ELEMENT\\s-+\\(" xml-name-re
+ "\\)\\s-+\\([^>]+\\)>")))
(or (null next-parameter-entity)
(<= (match-end 0) next-parameter-entity)))
(let ((element (match-string-no-properties 1))
@@ -659,13 +661,14 @@ This follows the rule [28] in the XML specifications."
(end-pos (match-end 0)))
;; Translation of rule [46] of XML specifications
(cond
- ((string-match "^EMPTY[ \t\n\r]*$" type) ; empty declaration
+ ((string-match "\\`EMPTY\\s-*\\'" type) ; empty declaration
(setq type 'empty))
- ((string-match "^ANY[ \t\n\r]*$" type) ; any type of contents
+ ((string-match "\\`ANY\\s-*$" type) ; any type of contents
(setq type 'any))
- ((string-match "^(\\(.*\\))[ \t\n\r]*$" type) ; children ([47])
- (setq type (xml-parse-elem-type (match-string-no-properties 1 type))))
- ((string-match "^%[^;]+;[ \t\n\r]*$" type) ; substitution
+ ((string-match "\\`(\\(.*\\))\\s-*\\'" type) ; children ([47])
+ (setq type (xml-parse-elem-type
+ (match-string-no-properties 1 type))))
+ ((string-match "^%[^;]+;[ \t\n\r]*\\'" type) ; substitution
nil)
(xml-validating-parser
(error "XML: (Validity) Invalid element type in the DTD")))