mirror of
https://git.savannah.gnu.org/git/emacs.git
synced 2025-02-08 20:58:58 +00:00
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
@ -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.
|
||||
(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 ()
|
||||
"Parse character data at point, and return it as a string.
|
||||
|
@ -72,7 +72,12 @@
|
||||
;; Invalid XML names
|
||||
"<0foo>abc</0foo>"
|
||||
"<‿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")
|
||||
|
||||
(defvar xml-parse-tests--qnames
|
||||
|
Loading…
x
Reference in New Issue
Block a user