philss/floki

Empty tag attributes are not parsed correctly

Closed this issue · 4 comments

iex(4)> Floki.parse_document("<a href></a>")
{:ok, [{"a", [{"href", "href"}], []}]}

Floki interprets this example as if it was <a href="href"> which is of course wrong. I would expect either Floki to represent the empty attribute as an empty string, or to omit it altogether.

Does not seem to affect fast_html

This is a limitation of the default parser, mochiweb_html. Please try to use FastHTML or HTML5ever as the README suggest.

@1player sorry, I didn't want to sound rude. My point was to point out that this is documented in our README: https://github.com/philss/floki?tab=readme-ov-file#alternative-html-parsers