ezyang / ezyang/htmlpurifier

CSS pseudo class "has()" not supported

Open
#397 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

Hi!

I have a case with this CSS in an email:

p:has(br:only-child) {
    margin: 0;
    display: none;
}

I'm using
$config->set('Filter.ExtractStyleBlocks', true);

The result is:

p {
    margin: 0;
    display: none;
}

Looks like neither "has()" nor ":only-child" is supported? ":first-child" is supported as far as I saw.

Can I add those 2 missing CSS pseudo selectors/classes somehow via configuration?

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

Start by tracing the ExtractStyleBlocks configuration into the CSS sanitization path and locating how pseudo-classes are handled. Use the supplied p:has(br:only-child) example as the acceptance case; done means these selectors are preserved or supported without regressing existing selectors such as :first-child.

Written by the indexing model from the issue text.

Assessment

Tech stack
css, php
Domain
security, web-dev
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
46/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.