[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] /srv/bzr/emacs/trunk r108825: * xml.el (xml-parse-dtd): Us
From: |
Chong Yidong |
Subject: |
[Emacs-diffs] /srv/bzr/emacs/trunk r108825: * xml.el (xml-parse-dtd): Use proper regexps for ELEMENT declarations. |
Date: |
Sun, 01 Jul 2012 19:05:17 +0800 |
User-agent: |
Bazaar (2.5.0) |
------------------------------------------------------------
revno: 108825
fixes bug: http://debbugs.gnu.org/7172
committer: Chong Yidong <address@hidden>
branch nick: trunk
timestamp: Sun 2012-07-01 19:05:17 +0800
message:
* xml.el (xml-parse-dtd): Use proper regexps for ELEMENT declarations.
* test/automated/xml-parse-tests.el: Update testcase.
modified:
lisp/ChangeLog
lisp/xml.el
test/automated/xml-parse-tests.el
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog 2012-07-01 07:17:05 +0000
+++ b/lisp/ChangeLog 2012-07-01 11:05:17 +0000
@@ -7,6 +7,7 @@
Use xml--parse-buffer.
(xml-parse-file): Use xml--parse-buffer.
(xml-parse-dtd): Make parameter entity substitution work right.
+ Use proper regexps for ELEMENT declarations (Bug#7172).
2012-06-30 Glenn Morris <address@hidden>
=== modified file 'lisp/xml.el'
--- a/lisp/xml.el 2012-07-01 07:17:05 +0000
+++ b/lisp/xml.el 2012-07-01 11:05:17 +0000
@@ -651,7 +651,9 @@
(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 @@
(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")))
=== modified file 'test/automated/xml-parse-tests.el'
--- a/test/automated/xml-parse-tests.el 2012-07-01 07:17:05 +0000
+++ b/test/automated/xml-parse-tests.el 2012-07-01 11:05:17 +0000
@@ -38,7 +38,10 @@
((foo ((a . "b")) (bar nil "AbC;"))))
;; Tricky parameter entity substitution (like XML spec Appendix D)
("<?xml version='1.0'?><!DOCTYPE foo [ <!ENTITY % xx '%zz;'><!ENTITY %
zz '<!ENTITY ent \"b\" >' > %xx; ]><foo>A&ent;C</foo>" .
- ((foo nil "AbC"))))
+ ((foo nil "AbC")))
+ ;; Bug#7172
+ ("<?xml version=\"1.0\"?><!DOCTYPE foo [ <!ELEMENT EXAM_PLE EMPTY>
]><foo></foo>" .
+ ((foo nil))))
"Alist of XML strings and their expected parse trees.")
(ert-deftest xml-parse-tests ()
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] /srv/bzr/emacs/trunk r108825: * xml.el (xml-parse-dtd): Use proper regexps for ELEMENT declarations.,
Chong Yidong <=