antisamy icon indicating copy to clipboard operation
antisamy copied to clipboard

Empty `@media` queries and custom media types

Open jonah1und1 opened this issue 5 months ago • 5 comments

I've introduced two bugs in my implementation to support @media rules:

  • AntiSamy throws a parsing exception on empty media queries: @media {...}
  • AntiSamy throws a parsing exception on custom media types, even if they are defined in the policy

Expected behaviour AntiSamy should be able to parse the media rule @media {} as no defined media type implies the media type all. When defining custom media types in the policy with the _mediatype css-rules property, these should not be filtered by AntiSamy.

Current behaviour For both these cases AntiSamy throws an CSSParseException. I've updated my example project with two corresponding tests:
https://github.com/jonah1und1/antisamy-media

Possible Solution I have created a PR with a possible solution: https://github.com/nahsra/antisamy/pull/597.
Please feel free to comment and/or review.

jonah1und1 avatar Jul 23 '25 14:07 jonah1und1

@spassarop - Can you look into this issue and the associated pull request?

davewichers avatar Jul 28 '25 13:07 davewichers

Looks good to me

spassarop avatar Aug 03 '25 16:08 spassarop

OK. So, I should merge PR #597, and mark this as fixed by that PR?

davewichers avatar Aug 04 '25 14:08 davewichers

Yes

Il giorno lun 4 ago 2025 alle 11:36 Dave Wichers @.***> ha scritto:

davewichers left a comment (nahsra/antisamy#596) https://github.com/nahsra/antisamy/issues/596#issuecomment-3151025599

OK. So, I should merge PR #597 https://github.com/nahsra/antisamy/pull/597, and mark this as fixed by that PR?

— Reply to this email directly, view it on GitHub https://github.com/nahsra/antisamy/issues/596#issuecomment-3151025599, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHL3BMO7PVJXJJD2F7XRGRD3L5VYHAVCNFSM6AAAAACCGDZ4YWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTCNJRGAZDKNJZHE . You are receiving this because you were mentioned.Message ID: @.***>

spassarop avatar Aug 04 '25 14:08 spassarop

The fix for this has been merged from PR #596 and will be included in the next release.

davewichers avatar Aug 04 '25 14:08 davewichers