ezyang / ezyang/htmlpurifier

ExtractStyleBlocks does not support @media

Open
#445 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
PHP
Stars
3.4k
Forks
361
Avg merge
3d 41m
Merged PRs (30d)
2

Description

$purifier = new \HTMLPurifier($config);
        

        $config = \HTMLPurifier_Config::createDefault();
        $config->set('Filter.ExtractStyleBlocks', true);
        $purifier = new \HTMLPurifier($config);
$clean_html = $purifier->purify(<<<HELLO
        <style> @media print { 
            div { color:red}
        } div { font-size:3em}</style><div>abc</div>
HELLO);

        $styles = $purifier->context->get('StyleBlocks');
        var_dump($styles);

Outputs

array(1) {
  [0]=>
  string(21) "div {
font-size:3em
}"
}

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The issue names no files or tests. Start by running the PHP reproduction and tracing the ExtractStyleBlocks path that produces StyleBlocks; done means the extracted output preserves the @media print block alongside the existing div rule.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.