Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow style element #10

Closed
kikz4life opened this issue Jan 18, 2018 · 1 comment
Closed

Allow style element #10

kikz4life opened this issue Jan 18, 2018 · 1 comment

Comments

@kikz4life
Copy link

Hi,

first of all thank you very much for this.

My question is how to accept <style></style>. I tried adding it in the config/purify but to no avail.
'HTML.Allowed' => 'style,div,b,strong,i,em,a[href|title],ul,ol,li,p[style],br,span[style],img[width|height|alt|src]',

@stevebauman
Copy link
Owner

stevebauman commented Feb 2, 2018

Hi @kikz4life, this is entirely an HTMLPurifier question since all my package is, is a wrapper allowing easy access and configuration.

This will be tricky, since it's actually invalid HTML for style tags to be inside of a web pages <body> and not in the <head>, so HTMLPurifier doesn't even allow for these to be inserted, since it could be exploited in various ways that it cannot protect against (disclaimer).

You'll actually need to extract any styles and insert them back into the content that the user has submitted. Here's the walk-through example from their documentation:

http://htmlpurifier.org/live/configdoc/plain.html#Filter.ExtractStyleBlocks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants