style attributes gets removed no matter what
Open
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 3.4k
- Forks
- 361
- Avg merge
- 3d 41m
- Merged PRs (30d)
- 2
Description
Hi I'm trying to allow the style attribute inside but it keeps getting removed no matter what I try.
This is my code :
$config = \HTMLPurifier_$config = \HTMLPurifier_Config::createDefault();
$config->set('Cache.DefinitionImpl', null);
$config->set('Core.Encoding', 'UTF-8'); // replace with your encoding
$config->set('HTML.Doctype', 'HTML 4.01 Transitional'); // replace with your doctype
$config->set('CSS.Trusted', true); // allow any css
$config->set('AutoFormat.RemoveEmpty', true);
$config->set('HTML.Allowed', 'div[style],b,strong,i,em,a[href|title],ul,ol,li,p[style],br,span[style],img[alt|style|src]'); //,*[style]
$config->set('HTML.AllowedElements', ['div', 'span', 'p', 'br', 'a', 'h1', 'h2', 'h3', 'h4', 'h5', 'strong', 'em', 'u', 'ul', 'li', 'ol', 'hr', 'blockquote', 'sub', 'sup', 'img']);
$config->set('HTML.AllowedAttributes', '*.style,*.title,*.href,*.src,*.border,*.alt,*.width,*.height,*.title');
$config->set('CSS.AllowedProperties', 'font-family');
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the reported sanitization with the configuration shown in the issue, especially the HTML.Allowed, HTML.AllowedAttributes, and CSS.AllowedProperties settings. Compare the configured allowances with the sanitized output and project documentation. Done means a span style attribute is preserved under the intended configuration without weakening unrelated filtering.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- security
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100