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

fix(isRgbColor): Fix validation of rgb(a)ColorPercentage strings #2114

Merged
merged 2 commits into from
Jan 29, 2023

Conversation

pano9000
Copy link
Contributor

@pano9000 pano9000 commented Dec 6, 2022

Fix validation of "rgb(a)ColorPercent" strings, see #2113
The current RegExp is missing the "end of string" anchor, so it will also match values with additional string content after the actual rgb color part, kindly check the issue above for examples.

This fixes #2113

Checklist

  • PR contains only changes related; no stray files, etc.
  • [ ] README updated (where applicable)
  • Tests written (where applicable)

@codecov
Copy link

codecov bot commented Dec 6, 2022

Codecov Report

Base: 100.00% // Head: 100.00% // No change to project coverage 👍

Coverage data is based on head (67ba926) compared to base (f97e8d4).
Patch coverage: 100.00% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff            @@
##            master     #2114   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          105       105           
  Lines         2335      2335           
  Branches       586       586           
=========================================
  Hits          2335      2335           
Impacted Files Coverage Δ
src/lib/isRgbColor.js 100.00% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

WikiRik
WikiRik previously approved these changes Dec 6, 2022
braaar
braaar previously approved these changes Dec 7, 2022
@braaar
Copy link
Contributor

braaar commented Dec 7, 2022

Are we concerned that this is a breaking change or do we see this more as a fix? Could there be someone out there who genuinely wants to permit some kind of trailing text, such as rgb(25, 25, 25);?

@pano9000
Copy link
Contributor Author

pano9000 commented Dec 7, 2022

I want to say no, that trailing semicolon would rather be part of CSS syntax, instead of the rgb color itself, don't you think?

on another note:
Generally speaking, I think isRgbColor could also be extended to also accept/validate rgb values, which do not have the rgb prefix, or e.g. also accept spaces between the values, but again - this is out of the scope of this PR and something for the future.

EDIT: Seems like the work has already been done or at least started here: #2029

@WikiRik
Copy link
Member

WikiRik commented Dec 7, 2022

I think that people should sanitize the input enough so there is no trailing text. Just like text added to the beginning.


Btw; we should do the same for isHSL as well right? I think we have the same issue there

@pano9000
Copy link
Contributor Author

pano9000 commented Dec 7, 2022

Btw; we should do the same for isHSL as well right? I think we have the same issue there

which issue exactly do you mean? if it is about trailing strings: That issue is not present in isHSL
Or is this about "extending" isHSL to allow spaces etc.?

@WikiRik
Copy link
Member

WikiRik commented Dec 7, 2022

Yeah, I was looking at the isHSL tests and didn't see any with trailing strings. I assumed that would mean it was also not implemented in the RegExp but I didn't check. But it seems that we only need to add additional tests for that.

rubiin
rubiin previously approved these changes Jan 21, 2023
@profnandaa profnandaa added the mc-to-land Just merge-conflict standing between the PR and landing. label Jan 28, 2023
@rubiin rubiin removed the mc-to-land Just merge-conflict standing between the PR and landing. label Jan 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

isRgbColor: Invalid rgb percentage strings are matched as valid
5 participants