Ali
Ali

Reputation: 1286

Skip sanitization for videos in html5lib

I am using a wmd-editor in django, much like this one in which I am typing. I would like to allow the users to embed videos in it. For that I am using the Markdown video extension here. The problem is that I am also sanitizing user input using html5lib sanitization and it doesn't allow object tags which are required to embed the videos.

One solution could be to check the input for urls of well-known video sites and skip the sanitization in those cases. Is there a better solution?

Upvotes: 2

Views: 362

Answers (1)

TryPyPy
TryPyPy

Reputation: 6434

A better solution would be to append 'object' to html5lib.sanitizer.HTMLSanitizer.acceptable_elements. A great solution would be to subclass html5lib.sanitizer.HTMLSanitizer so you can conditionally accept or remove the object in sanitize_token.

The implementation seems clear enough to tackle.

Upvotes: 3

Related Questions