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.
This commit is contained in:
parent
100346aa22
commit
8b01e6969f
2 changed files with 14 additions and 2 deletions
|
@ -579,7 +579,14 @@ Return one of:
|
||||||
(error "XML: (Well-Formed) Invalid character"))
|
(error "XML: (Well-Formed) Invalid character"))
|
||||||
;; However, if we're parsing incrementally, then we need to deal
|
;; However, if we're parsing incrementally, then we need to deal
|
||||||
;; with stray CDATA.
|
;; with stray CDATA.
|
||||||
(xml-parse-string)))))
|
(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"
|
||||||
|
(buffer-substring-no-properties
|
||||||
|
(point) (min (+ (point) 10) (point-max)))))
|
||||||
|
s)))))
|
||||||
|
|
||||||
(defun xml-parse-string ()
|
(defun xml-parse-string ()
|
||||||
"Parse character data at point, and return it as a string.
|
"Parse character data at point, and return it as a string.
|
||||||
|
|
|
@ -72,7 +72,12 @@
|
||||||
;; Invalid XML names
|
;; Invalid XML names
|
||||||
"<0foo>abc</0foo>"
|
"<0foo>abc</0foo>"
|
||||||
"<‿foo>abc</‿foo>"
|
"<‿foo>abc</‿foo>"
|
||||||
"<f¿>abc</f¿>")
|
"<f¿>abc</f¿>"
|
||||||
|
;; Two root tags
|
||||||
|
"<a/><b></b>"
|
||||||
|
;; Bug#16344
|
||||||
|
"<!----><x>< /x>"
|
||||||
|
"<a>< b/></a>")
|
||||||
"List of XML strings that should signal an error in the parser")
|
"List of XML strings that should signal an error in the parser")
|
||||||
|
|
||||||
(defvar xml-parse-tests--qnames
|
(defvar xml-parse-tests--qnames
|
||||||
|
|
Loading…
Add table
Reference in a new issue