diff options
author | Ulf Jasper <ulf.jasper@web.de> | 2016-03-02 19:03:27 +0100 |
---|---|---|
committer | Ulf Jasper <ulf.jasper@web.de> | 2016-03-02 19:03:27 +0100 |
commit | 8b01e6969f9e53a226d489cb721a7493fb3ad2de (patch) | |
tree | 8f3dfe1bf72a4813a3bcda17644f8c784ce2639c /lisp/xml.el | |
parent | 100346aa226e4eacc56f390c099bb9aab585b5f4 (diff) | |
download | emacs-8b01e6969f9e53a226d489cb721a7493fb3ad2de.tar.gz |
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.
Diffstat (limited to 'lisp/xml.el')
-rw-r--r-- | lisp/xml.el | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/lisp/xml.el b/lisp/xml.el index 2c3b6a49f61..1802d04dfaf 100644 --- a/lisp/xml.el +++ b/lisp/xml.el @@ -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. |