html5lib seems to be stripping attribute quotes, which can have some
undesirable effects.

If the attribute in question is the last (or only) in an opening tag,
and the attribute value ends with a forward slash or solidus (/), the
some parsers (namely jQuery's `.html()`, currently) will interpret
this as a self-closing tag.

I do contend this is a jQuery bug, but they do not currently recognize
it as such:
http://bugs.jquery.com/ticket/9530


Example input and output, that triggers this behavior in some parsers:

=======

<p>Hello! <a href="http://google.com/";>Google</a> <a href=http://
yahoo.com/>Yahoo</a></p>

 - - - - - - - -

<html><head></head><body><p>Hello! <a href=http://google.com/>Google</
a> <a href=http://yahoo.com/>Yahoo</a></p></body></html>

======

Note that *both* links above end up with an unquoted attribute value.

The problem is, of course, that the problematic parsers fixate on the
`/>` string in the input.

By the time a fragment of the above output is inserted via
jQuery .html, it is interpreted like this in the DOM:

======

<html><head></head><body><p>Hello! <a href=http://google.com>Google</
a> <a href=http://yahoo.com></a>Yahoo</p>

======

Note not only that the <a> tags are closed prematurely, as empty tags,
but also that the href attribute itself has now changed and lost the
trailing slash.

Is there a way to always quote attributes or otherwise prevent this
from occurring?

-- 
You received this message because you are subscribed to the Google Groups 
"html5lib-discuss" group.
To post to this group, send an email to html5lib-discuss@googlegroups.com.
To unsubscribe from this group, send email to 
html5lib-discuss+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/html5lib-discuss?hl=en-GB.

Reply via email to