;;; xml.el --- XML parser
-;; Copyright (C) 2000-2013 Free Software Foundation, Inc.
+;; Copyright (C) 2000-2016 Free Software Foundation, Inc.
;; Author: Emmanuel Briot <briot@gnat.com>
;; Maintainer: Mark A. Hershberger <mah@everybody.org>
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))
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
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
(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.
(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)