Commit 8b01e696 authored by Ulf Jasper's avatar Ulf Jasper

Prevent infinite loop on not-well-formed xml. (Bug#16344)

* lisp/xml.el (xml-parse-tag-1): Prevent inifinite loop. (Bug#16344)
* test/automated/xml-parse-tests.el (xml-parse-tests--bad-data): Add
  test cases for Bug#16344.
parent 100346aa
......@@ -579,7 +579,14 @@ Return one of:
(error "XML: (Well-Formed) Invalid character"))
;; However, if we're parsing incrementally, then we need to deal
;; with stray CDATA.
(let ((s (xml-parse-string)))
(when (string-empty-p s)
;; We haven't consumed any input! We must throw an error in
;; order to prevent looping forever.
(error "XML: (Not Well-Formed) Could not parse: %s"
(point) (min (+ (point) 10) (point-max)))))
(defun xml-parse-string ()
"Parse character data at point, and return it as a string.
......@@ -72,7 +72,12 @@
;; Invalid XML names
;; Two root tags
;; Bug#16344
"<!----><x>< /x>"
"<a>< b/></a>")
"List of XML strings that should signal an error in the parser")
(defvar xml-parse-tests--qnames
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment