diff lisp/xml.el @ 109288:e24d55cee016

* xml.el (xml-parse-region): Avoid infloop (Bug#5281).
author Chong Yidong <cyd@stupidchicken.com>
date Wed, 30 Jun 2010 16:34:06 -0400
parents 1d1d5d9bd884
children 376148b31b5e
line wrap: on
line diff
--- a/lisp/xml.el	Wed Jun 30 10:22:18 2010 -0400
+++ b/lisp/xml.el	Wed Jun 30 16:34:06 2010 -0400
@@ -321,18 +321,20 @@
 		(progn
 		  (forward-char -1)
 		  (setq result (xml-parse-tag parse-dtd parse-ns))
-		  (if (and xml result (not xml-sub-parser))
-		      ;;  translation of rule [1] of XML specifications
-		      (error "XML: (Not Well-Formed) Only one root tag allowed")
-		    (cond
-		     ((null result))
-		     ((and (listp (car result))
-			   parse-dtd)
-		      (setq dtd (car result))
-		      (if (cdr result)	; possible leading comment
-			  (add-to-list 'xml (cdr result))))
-		     (t
-		      (add-to-list 'xml result)))))
+		  (cond
+		   ((null result)
+		    ;; Not looking at an xml start tag.
+		    (forward-char 1))
+		   ((and xml (not xml-sub-parser))
+		    ;; Translation of rule [1] of XML specifications
+		    (error "XML: (Not Well-Formed) Only one root tag allowed"))
+		   ((and (listp (car result))
+			 parse-dtd)
+		    (setq dtd (car result))
+		    (if (cdr result)	; possible leading comment
+			(add-to-list 'xml (cdr result))))
+		   (t
+		    (add-to-list 'xml result))))
 	      (goto-char (point-max))))
 	  (if parse-dtd
 	      (cons dtd (nreverse xml))