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

Check for malformed colors. #3

Closed
tomByrer opened this issue Feb 22, 2020 · 2 comments
Closed

Check for malformed colors. #3

tomByrer opened this issue Feb 22, 2020 · 2 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@tomByrer
Copy link
Contributor

Related to my demo PR

Not sure what the result should be. Could just fall back to default foreground & background defaults, or find a way to make a readable auto-fix (IIRC TinyColor). I don't think returning an error is a good idea, though perhaps sneaking a small error text (comment?) in the SVG could work.

Bonus: if you use TinyColor or roll your own fixer code, you could expose the checker &/or fixer as its own APIs....

If you need RegEx help:
RegexHQ on Github 😎
https://regexr.com 'Community Patterns"
https://regex101.com
Though color names will be an issue....

@Cherry
Copy link
Owner

Cherry commented Feb 23, 2020

I'm actually already using validate-color to validate colour inputs as per

function sanitizeColor(input){
. It works reasonably well, but it's definitely possible to get some malformed data through it if you try hard enough.

I'm honestly not sure I care too much though. If people end up creating malformed SVGs, that's kinda on them. I've fixed the possibility to exploit with XSS as per #1 so the only real problem here is a malformed SVG.

I could possibly run the generated SVGs through a validator before serving it, and then perhaps just defaulting if the SVG comes back as invalid though.

@Cherry Cherry added enhancement New feature or request help wanted Extra attention is needed labels Feb 23, 2020
@Cherry
Copy link
Owner

Cherry commented Dec 9, 2023

Going to close this with the addition of testing in #26. The colour validation seems pretty solid now, but please feel free to create a PR with failing tests or let me know if you have anything that gets through it!

@Cherry Cherry closed this as completed Dec 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants