Subject: Re: bug#46764: Extra ">" sails right past XML validator

From: Lars Ingebrigtsen <[email-masked]>
Date: Thu, 25 Feb 2021 16:48:59 +0100

積丹尼 Dan Jacobson <[email-masked]> writes:

> $ cat e.xml
> <?xml version="1.0" encoding="utf-8" ?>
> <M>></M>
> $ emacs e.xml
> says at the bottom: (nXML Valid)

I can confirm that this problem still exists in Emacs 28.

It seems to stem from this bit of code:

(defun xmltok-forward ()
  (setq xmltok-start (point))
  (let* ((case-fold-search nil)
	 (space-count (skip-chars-forward " \t\r\n"))
	 (ch (char-after)))
    (cond ((eq ch ?\<)
	   (cond ((> space-count 0)
		  (setq xmltok-type 'space))
		 (t
		  (forward-char 1)
		  (xmltok-scan-after-lt))))
	  ((eq ch ?\&)
	   (cond ((> space-count 0)
		  (setq xmltok-type 'space))
		 (t
		  (forward-char 1)
		  (xmltok-scan-after-amp 'xmltok-handle-entity))))
	  ((re-search-forward "[<&]\\|\\(]]>\\)" nil t)
	   (cond ((not (match-beginning 1))

So (xmltok-forward) on the ">" will just return `data'.  Is it checking
just < and & for validity on purpose?  Anybody remember what the thought
process might have been here?

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no