[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
xml.el doesn't handle empty attributes correctly
From: |
Rob Austein |
Subject: |
xml.el doesn't handle empty attributes correctly |
Date: |
Sat, 24 Sep 2005 15:10:18 -0400 |
Problem:
XML attribute values can be empty, but xml.el doesn't allow that.
The regexps in xml.el are wrong.
Example:
bash$ cat xml-bug.el
(message "Emacs version: %s" emacs-version)
(defun test ()
(prin1-to-string
(let ((buf (get-buffer-create "xml-bug")))
(princ "<foo bar=''/>" buf)
(set-buffer buf)
(message "Test buffer: %s" (buffer-string))
(unwind-protect
(let (cc)
(condition-case cc
(xml-parse-region (point-min) (point-max))
(error cc)))
(kill-buffer buf)))))
(load "/usr/local/share/emacs/21.3/lisp/xml.el")
(message "Parse result: %s" (test))
(load "/tmp/xml.el")
(message "Parse result: %s" (test))
bash$ emacs -batch -l xml-bug.el
Emacs version: 21.3.1
Loading /usr/local/share/emacs/21.3/lisp/xml.el (source)...
Test buffer: <foo bar=''/>
Parse result: (error "XML: Attribute values must be given between quotes")
Loading /tmp/xml.el (source)...
Test buffer: <foo bar=''/>
Parse result: ((foo ((bar . "")) ""))
Patch:
--- /usr/local/share/emacs/21.3/lisp/xml.el Thu Oct 18 20:19:51 2001
+++ /tmp/xml.el Sat Sep 24 18:39:53 2005
@@ -289,8 +289,8 @@
;; Do we have a string between quotes (or double-quotes),
;; or a simple word ?
- (unless (looking-at "\"\\([^\"]+\\)\"")
- (unless (looking-at "'\\([^']+\\)'")
+ (unless (looking-at "\"\\([^\"]*\\)\"")
+ (unless (looking-at "'\\([^']*\\)'")
(error "XML: Attribute values must be given between quotes")))
;; Each attribute must be unique within a given element
--Rob
- xml.el doesn't handle empty attributes correctly,
Rob Austein <=