Menu

#3842 HTML syntax highlighting error: & in href

minor bug
closed-fixed
5
2014-08-22
2013-11-07
No

I've got an img element with an href inside it that contains an & character for a second URL parameter. It's a Google Maps static image API call, a la https://developers.google.com/maps/documentation/staticmaps. This breaks the subsequent syntax highlighting. I've installed the latest HTML edit mode, but it's still happening.

I'm on jEdit 5.1.0 server mode, running on Java 1.7.0_45.

Discussion

  • robertlagrant

    robertlagrant - 2013-11-07

    Line after img element should have normal highlighting; it doesn't.

     
  • Matthieu Casanova

    • status: open --> pending
     
  • Matthieu Casanova

    I don't understand, you just have to encode & as & and it is solved right ?

     
  • Marc Häfner

    Marc Häfner - 2013-11-07

    Yes, encoding would resolve the issue (and not confuse the XML plugin). But HTML5 (and all major browsers) do actually allow unencoded ampersands. The slightly horrible details: http://www.w3.org/TR/html5/syntax.html#consume-a-character-reference

    Syntax highlighting should handle that situation better. A fix is underway. But it will not completely cover the specification, because I won't put 2125 named character references in the mode file, or any for that matter...

    (Another issue would be the XML plugin that seems to insist on encoded ampersands.)

     
  • Eric Le Lay

    Eric Le Lay - 2013-11-07

    The recommendation states that it is allowed for "historical reasons".
    The XML plugin should not encourage these broken cases.
    When syntax highlighting is broken a careless insertion of copy-pasted url is detected.

     
  • Marc Häfner

    Marc Häfner - 2013-11-08

    A fixed version can be found at https://raw.github.com/marchaefner/jEdit-modes/master/html.xml

    Unencoded ampersands (that don't seem to be the start of an SGML character entity) are now marked as INVALID and don't impact subsequent highlighting.

    This compromise between HTML5 and previous versions, which are all highlighted with this mode, hopefully addresses all concerns. (I retract any points I may have made about the XML plugin, it's working fine enough.)

    Patch #3614699 will be updated shortly.

     
  • Dale Anson

    Dale Anson - 2014-02-15
    • assigned_to: Dale Anson
     
  • Dale Anson

    Dale Anson - 2014-02-15
    • status: pending --> closed-fixed
     
  • Dale Anson

    Dale Anson - 2014-02-15

    Fixed in svn revision 23418.

     

Log in to post a comment.