all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* xml.el doesn't handle empty attributes correctly
@ 2005-09-24 19:10 Rob Austein
  0 siblings, 0 replies; 2+ messages in thread
From: Rob Austein @ 2005-09-24 19:10 UTC (permalink / raw)


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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2005-09-26  3:15 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <E1EJga6-0002OE-6V@fencepost.gnu.org>
2005-09-26  3:15 ` xml.el doesn't handle empty attributes correctly Mark A. Hershberger
2005-09-24 19:10 Rob Austein

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.