X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/adf2fc4a01efe77d73cd52bc9173914ed56ff531..fdcf46d33eebc59e56a35fcea186c61aad3c81d0:/lisp/xml.el diff --git a/lisp/xml.el b/lisp/xml.el index b62065eb48..414300cb40 100644 --- a/lisp/xml.el +++ b/lisp/xml.el @@ -1,6 +1,6 @@ ;;; xml.el --- XML parser -;; Copyright (C) 2000-2013 Free Software Foundation, Inc. +;; Copyright (C) 2000-2016 Free Software Foundation, Inc. ;; Author: Emmanuel Briot ;; Maintainer: Mark A. Hershberger @@ -126,9 +126,9 @@ tag. For example, would be represented by - '(\"\" . \"foo\"). + (\"\" . \"foo\"). -If you'd just like a plain symbol instead, use 'symbol-qnames in +If you'd just like a plain symbol instead, use `symbol-qnames' in the PARSE-NS argument." (car node)) @@ -326,8 +326,8 @@ URIs, and expanded names will be returned as a cons If PARSE-NS is an alist, it will be used as the mapping from namespace to URIs instead. -If it is the symbol 'symbol-qnames, expanded names will be -returned as a plain symbol 'namespace:foo instead of a cons. +If it is the symbol `symbol-qnames', expanded names will be +returned as a plain symbol `namespace:foo' instead of a cons. Both features can be combined by providing a cons cell @@ -356,8 +356,8 @@ URIs, and expanded names will be returned as a cons If PARSE-NS is an alist, it will be used as the mapping from namespace to URIs instead. -If it is the symbol 'symbol-qnames, expanded names will be -returned as a plain symbol 'namespace:foo instead of a cons. +If it is the symbol `symbol-qnames', expanded names will be +returned as a plain symbol `namespace:foo' instead of a cons. Both features can be combined by providing a cons cell @@ -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 (zerop (length 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. @@ -1010,12 +1017,12 @@ The first line is indented with the optional INDENT-STRING." (defun xml-escape-string (string) "Convert STRING into a string containing valid XML character data. -Replace occurrences of &<>'\" in STRING with their default XML -entity references (e.g. replace each & with &). +Replace occurrences of &<>\\='\" in STRING with their default XML +entity references (e.g., replace each & with &). XML character data must not contain & or < characters, nor the > character under some circumstances. The XML spec does not impose -restriction on \" or ', but we just substitute for these too +restriction on \" or \\=', but we just substitute for these too \(as is permitted by the spec)." (with-temp-buffer (insert string)