Empty `@media` queries and custom media types
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.
@spassarop - Can you look into this issue and the associated pull request?
Looks good to me
OK. So, I should merge PR #597, and mark this as fixed by that PR?
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: @.***>
The fix for this has been merged from PR #596 and will be included in the next release.