rgrove / sanitize

Ruby HTML and CSS sanitizer.
MIT License
2.02k stars 142 forks source link

Invalid closing tags added to track and source tags #196

Closed sarken closed 5 years ago

sarken commented 5 years ago

When using the <track> and <source> elements inside an <audio> or <video> element, closing </track> and </source> tags are automatically added.

Example input:

<video>
<source src="some url" type="video/mp4">
<track label="English" kind="subtitles" srclang="en" src="url">
</video>

Example output:

<video>
<source src="some url" type="video/mp4"></source>
<track label="English" kind="subtitles" srclang="en" src="url"></track>
</video>

However, if you run the resultant code through the W3 Validator, it gives a "Stray end tags" error about </track> and </source>.

So the desired output would be:

<video>
<source src="some url" type="video/mp4">
<track label="English" kind="subtitles" srclang="en" src="url">
</video>

We're on Ruby 2.6.5 and Sanitize version 4.6.5, and our audio and video tag sanitizer is here in case you need to look at our implementation. Running the HTML through nokogiri does not add the closing tags.

sarken commented 5 years ago

We tested a more recent version of the gem and that fixed the issue, so I will close this! Apologies for the invalid report and not checking the obvious solution first.

rgrove commented 5 years ago

No worries. Glad to hear the newer version solved your problem!