Should backslashes not be treated specially in XML files?

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Should backslashes not be treated specially in XML files?

adah
All by accident I found that a `\' caused a whole XML file to be
highlighted wrongly in Vim. I searched the XML specification and found
nothing that should make a parser think `\' starts an escape sequence. So
I think this might be a bug in xml.vim.

I am currently running gVim 6.3.84.

Best regards,

Yongwei
Reply | Threaded
Open this post in threaded view
|

Re: Should backslashes not be treated specially in XML files?

adah
Wu Yongwei wrote:
> All by accident I found that a `\' caused a whole XML file to be
> highlighted wrongly in Vim. I searched the XML specification and found
> nothing that should make a parser think `\' starts an escape sequence.
> So I think this might be a bug in xml.vim.

I do not know why there have been no comments on this, but I have
proceeded to work out a fix.  Just two lines need to be changed in
xml.vim.  Ll. 61-62 were:

syn region  xmlString contained start=+"+ skip=+\\\\\|\\"+ end=+"+
contains=xmlEntity display
syn region  xmlString contained start=+'+ skip=+\\\\\|\\'+ end=+'+
contains=xmlEntity display

I changed them to:

syn region  xmlString contained start=+"+ end=+"+ contains=xmlEntity
display
syn region  xmlString contained start=+'+ end=+'+ contains=xmlEntity
display

If it is OK, please make it official.  If not, please comment.

BTW, the relevant part of the XML specification is:

AttValue    ::=    '"' ([^<&"] | Reference)* '"'
                 | "'" ([^<&'] | Reference)* "'"
Reference   ::=    EntityRef | CharRef
EntityRef   ::=    '&' Name ';'
CharRef     ::=    '&#' [0-9]+ ';'
                 | '&#x' [0-9a-fA-F]+ ';'

Best regards,

Yongwei
Reply | Threaded
Open this post in threaded view
|

RE: Should backslashes not be treated specially in XML files?

Gareth Oakes-2
In reply to this post by adah
Your fix looks good to me, backslashes should not be treated specially inside attribute values (as we're all probably aware, the way to escape special characters is with the correct predefined XML entities - &quot; &lt; &gt; etc.).
 
I'm guessing you may need to contact the listed maintainer (Johannes Zellner) to get this fix committed?
 
-Gareth

________________________________

From: [hidden email] [mailto:[hidden email]]
Sent: Tue 23/08/2005 07:02
To: [hidden email]
Subject: Re: Should backslashes not be treated specially in XML files?



Wu Yongwei wrote:
> All by accident I found that a `\' caused a whole XML file to be
> highlighted wrongly in Vim. I searched the XML specification and found
> nothing that should make a parser think `\' starts an escape sequence.
> So I think this might be a bug in xml.vim.

I do not know why there have been no comments on this, but I have
proceeded to work out a fix.  Just two lines need to be changed in
xml.vim.  Ll. 61-62 were:

syn region  xmlString contained start=+"+ skip=+\\\\\|\\"+ end=+"+
contains=xmlEntity display
syn region  xmlString contained start=+'+ skip=+\\\\\|\\'+ end=+'+
contains=xmlEntity display

I changed them to:

syn region  xmlString contained start=+"+ end=+"+ contains=xmlEntity
display
syn region  xmlString contained start=+'+ end=+'+ contains=xmlEntity
display

If it is OK, please make it official.  If not, please comment.

BTW, the relevant part of the XML specification is:

AttValue    ::=    '"' ([^<&"] | Reference)* '"'
                 | "'" ([^<&'] | Reference)* "'"
Reference   ::=    EntityRef | CharRef
EntityRef   ::=    '&' Name ';'
CharRef     ::=    '&#' [0-9]+ ';'
                 | '&#x' [0-9a-fA-F]+ ';'

Best regards,

Yongwei

Reply | Threaded
Open this post in threaded view
|

Re: Should backslashes not be treated specially in XML files?

Bram Moolenaar
In reply to this post by adah

> Wu Yongwei wrote:
> > All by accident I found that a `\' caused a whole XML file to be
> > highlighted wrongly in Vim. I searched the XML specification and found
> > nothing that should make a parser think `\' starts an escape sequence.
> > So I think this might be a bug in xml.vim.
>
> I do not know why there have been no comments on this, but I have
> proceeded to work out a fix.  Just two lines need to be changed in
> xml.vim.  Ll. 61-62 were:

This fix has already been included.  The updated runtime files are
available, see here: http://www.vim.org/runtime.php

--
From "know your smileys":
 :-F Bucktoothed vampire with one tooth missing

 /// Bram Moolenaar -- [hidden email] -- http://www.Moolenaar.net   \\\
///        Sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\              Project leader for A-A-P -- http://www.A-A-P.org        ///
 \\\     Buy LOTR 3 and help AIDS victims -- http://ICCF.nl/lotr.html   ///
Reply | Threaded
Open this post in threaded view
|

Re: Should backslashes not be treated specially in XML files?

adah
In reply to this post by adah
Bram Moolenaar wrote:
> > Wu Yongwei wrote:
> > > All by accident I found that a `\' caused a whole XML file to be
> > > highlighted wrongly in Vim. I searched the XML specification and
found
> > > nothing that should make a parser think `\' starts an escape
sequence.
> > > So I think this might be a bug in xml.vim.
> >
> > I do not know why there have been no comments on this, but I have
> > proceeded to work out a fix.  Just two lines need to be changed in
> > xml.vim.  Ll. 61-62 were:
>
> This fix has already been included.  The updated runtime files are
> available, see here: http://www.vim.org/runtime.php

Thanks Bram.  Next time I shall try updating the runtime files first.

Best regards,

Yongwei