htmlpurifier icon indicating copy to clipboard operation
htmlpurifier copied to clipboard

feature-request: css attribute selectors

Open Daijobou opened this issue 10 years ago • 6 comments

Maybe anyone can create a pull request for css attribute selectors or has a solution? http://www.w3schools.com/css/css_attribute_selectors.asp

htmlpurifier remove attributes in css. I need this two variants: [attribute] and [attribute="value"]

Daijobou avatar Jan 06 '16 12:01 Daijobou

This is using CSSTidy? I don't think you can do attribute selectors in inline CSS.

ezyang avatar Jul 01 '16 19:07 ezyang

I don't need it for inline CSS. :)

You need it for two cases. A html-file with <style> in it or to check a css-file. I use both.

Daijobou avatar Jul 28 '16 10:07 Daijobou

I'm running into this exact situation. Using HTMLPurifier & CSSTidy — the output is stripping rules like .fonts-stage-2 [aria-label][data-balloon-pos]:after{color:#fff;}

I'm using the latest versions of both utilities.

seezee avatar Feb 24 '21 22:02 seezee

Big Q here is whether or not CSSTidy understands attribute selectors. If it does, it's probably just a matter of tweaking HTML Purifier code to stop stripping them out. If it doesn't, that's going to be more work, and an update to CSSTidy

ezyang avatar Feb 28 '21 01:02 ezyang

AFAIK, CSSTidy does understand attribute selectors. See this issue. https://github.com/Cerdic/CSSTidy/issues/47

Thanks,

— CZ

On 27Feb 2021, at 7:40 PM, Edward Z. Yang [email protected] wrote:

Big Q here is whether or not CSSTidy understands attribute selectors. If it does, it's probably just a matter of tweaking HTML Purifier code to stop stripping them out. If it doesn't, that's going to be more work, and an update to CSSTidy

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/ezyang/htmlpurifier/issues/69#issuecomment-787217375, or unsubscribe https://github.com/notifications/unsubscribe-auth/AACGIXEOREOZ6KZGKVFMQLDTBGNJVANCNFSM4BX6IK6Q.

seezee avatar Feb 28 '21 17:02 seezee

OK, so someone just has to go to library/HTMLPurifier/Filter/ExtractStyleBlocks.php and extend the selector processing code to add attribute selectors (and make sure you don't introduce any security vulnerabilities in the process)

ezyang avatar Mar 01 '21 03:03 ezyang