* xml.el (xml-parse-region): Avoid infloop (Bug#5281).
authorChong Yidong <cyd@stupidchicken.com>
Wed, 30 Jun 2010 20:34:06 +0000 (16:34 -0400)
committerChong Yidong <cyd@stupidchicken.com>
Wed, 30 Jun 2010 20:34:06 +0000 (16:34 -0400)
lisp/ChangeLog
lisp/xml.el

index b634bcd..45d12bf 100644 (file)
@@ -1,3 +1,7 @@
+2010-06-30  Chong Yidong  <cyd@stupidchicken.com>
+
+       * xml.el (xml-parse-region): Avoid infloop (Bug#5281).
+
 2010-06-29  Leo  <sdl.web@gmail.com>
 
        * emacs-lisp/rx.el (rx): Doc fix.  (Bug#6537)
index 20b595f..8e8981a 100644 (file)
@@ -321,18 +321,20 @@ If PARSE-NS is non-nil, then QNAMES are expanded."
                (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))