Selector for element with attribute is lost
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 3.4k
- Forks
- 361
- Avg merge
- 3d 41m
- Merged PRs (30d)
- 2
Description
Hi 👋
We are using htmlpurifier for nextcloud/mail to sanitize the body of html messages and have a bug report that a mail is not rendered correctly (https://github.com/nextcloud/mail/issues/5279).
I debugged the mail body and found that
* img[tabindex="0"] + div {
text-align:center
}
is rewritten to
* + div {
text-align:center
}

A test case for ExtractStyleBlocksTest:
public function test_cleanCSS_elementWithAttribute()
{
$this->assertCleanCSS(
"* img[tabindex=\"0\"] + div {\ntext-align:center\n}",
"* img + div {\ntext-align:center\n}"
);
}
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 in library/HTMLPurifier/Filter/ExtractStyleBlocks.php around the referenced selector handling, then run or inspect ExtractStyleBlocksTest. Add the provided test case and ensure the cleaned CSS retains the attribute selector in the output. Done means the regression test passes without breaking the existing cleaning behavior.
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
- Clearly specified
- Newbie friendliness
- 55/100