Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IllegalStateException on rgb percentage values #546

Open
jonah1und1 opened this issue Jan 20, 2025 · 5 comments
Open

IllegalStateException on rgb percentage values #546

jonah1und1 opened this issue Jan 20, 2025 · 5 comments

Comments

@jonah1und1
Copy link
Contributor

jonah1und1 commented Jan 20, 2025

Antisamy seems to have an issue with parsing rgb percentage values such as rgb(50%, 50%, 50%).

Expected bahaviour
Percentage colour values should be parsed just like integer values between 0 and 255. Scanning the following style tag should not yield any errors:

<style>.cl { color: rgb(50%, 20%, 50%); }</style>

Current behaviour
Scanning aforementioned style tag results in antisamy throwing an IllegalStateException.
I've created an example project with a corresponding test:
https://github.com/jonah1und1/antisamy-rgb-percentage .

Possible fixes
I assume the problem could be mitigated by explicitly handling percentages for rgb colours in CssValidator.java:343.
I have created a pull request with a possible fix: #547.
Please feel free to review.

jonah1und1 added a commit to jonah1und1/antisamy that referenced this issue Jan 20, 2025
@jonah1und1
Copy link
Contributor Author

This issue seems to exist for some time now. It is mentioned here:
https://code.google.com/archive/p/owaspantisamy/issues/139
and here:
https://code.google.com/archive/p/owaspantisamy/issues/189.

@davewichers
Copy link
Collaborator

@spassarop - This is the issue that the pull request is trying to address.

@spassarop
Copy link
Collaborator

@jonah1und1 Thanks for your proposed fix. I agree it can be tackled the way you did, however, I added some comments that will improve the solution and also match the kind of behavior we expect when creating a fix for AntiSamy outputs.

@jonah1und1
Copy link
Contributor Author

@spassarop Thank you for your answer and review. Unfortunately, I was not able to find your comments. Could you please point me to them?

jonah1und1 added a commit to jonah1und1/antisamy that referenced this issue Jan 24, 2025
davewichers pushed a commit that referenced this issue Jan 26, 2025
* fix(gh-546): bug which resulted in an IllegalStateException for percentage rgb values

* fix(gh-546): keep colour percentages in sanitized css instead of converting them to int
@davewichers
Copy link
Collaborator

This issue has been fixed in main. Will go out in next release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants