-
-
Notifications
You must be signed in to change notification settings - Fork 79.1k
Improve build/generate-sri.js regex #29753
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
Conversation
Sorry, my bad! I forgot to run |
@Noah2610 please remove any dist files :) |
@XhmikosR Remove the dist files from my fork? Or where do you mean? |
From your branch. No dist files should be touched. |
Do not delete the dist files... just don't touch them in your patch |
When using single-quotes in config.yml, the previous regular expression in build/generate-cli.js wasn't working correctly, it was replacing ALL string values with hashes. Now both double- and single-quotes can be used in config.yml, and the RegExp will work as expected.
39529f2
to
bc938dc
Compare
I'm sorry, I'm not following... I haven't touched the dist/ files in my original commit. I'm sorry for any trouble I'm causing! Would you mind explaining to me what I'm doing wrong? |
You deleted the dist files when you shouldn't have touched them in the first place. I fixed it, please don't overwrite the changes. |
Up to you whether we keep this @XhmikosR. |
Still need to test this out, I forgot it even existed :P |
I mean I'm fine leaving it as-is given it works for us. Still your call. |
@Noah2610 can you please make a https://regex101.com/ example? We don't really hit this issue, but if it helps other people we can consider merging it. PS. any reason you don't use non-capturing groups? |
Cleanup the regex a bit, remove unnecessary capture-groups.
@XhmikosR Here's the regex101: https://regex101.com/r/Yhl9vL/1 I don't remember why I went so heavy on the capturing-groups. I cleaned it up a bit in the last commit. |
Perfect, thanks! I can quickly confirm this is fine since the Netlify preview doesn't throw any SRI mismatch errors, but I'll test it later more and merge it soon. I'll also backport this to v4-dev if/after this lands. |
One last thing: any reason you switched to |
Did I? I don't see any |
We might as well specify EDIT: scratch the comment about |
Oh sorry, I see now. And yeah, I'll add the |
I edited directly the file, let me know if everything still looks good to you. If you can, please also update your regex101 example. |
Perfect, I think everything's is fine, but I'll test later again. Thanks! |
https://regex101.com/r/Yhl9vL/3 I added a badly formatted yaml line to the end of the example string to showcase why EDIT: Although the whitespace at the start of the line is invalid yaml in this case, so the first |
So, basically, only the second |
The first Another thing I noticed, is that we probably shouldn't have a Here's the updated regex101: https://regex101.com/r/Yhl9vL/4 I'll update the script and test it locally before I commit. |
Well, TBH, I don't think we should cover all those cases. The script is supposed to be used internally, and it's OK to make a small change to take care of your issue, but I don't think we should care about all the other cases. |
I understand. |
Also, nevermind, yaml requires a space after the |
OK, so what's your final suggestion? |
I'd use the regex in the last version of the regex101: https://regex101.com/r/Yhl9vL/5 |
Cool, let's go with that then 👍 |
When using single-quotes in config.yml, the previous regular expression in build/generate-cli.js wasn't working correctly, it was replacing ALL string values with hashes. Now both double- and single-quotes can be used in config.yml, and the RegExp will work as expected. Also, allow trailing whitespaces and empty ("") values to be matched. Co-authored-by: XhmikosR <xhmikosr@gmail.com>
When using single-quotes in config.yml, the previous regular expression in build/generate-cli.js wasn't working correctly, it was replacing ALL string values with hashes. Now both double- and single-quotes can be used in config.yml, and the RegExp will work as expected. Also, allow trailing whitespaces and empty ("") values to be matched. Co-authored-by: XhmikosR <xhmikosr@gmail.com>
When using single-quotes in config.yml, the previous regular expression in build/generate-cli.js wasn't working correctly, it was replacing ALL string values with hashes. Now both double- and single-quotes can be used in config.yml, and the RegExp will work as expected. Also, allow trailing whitespaces and empty ("") values to be matched. Co-authored-by: XhmikosR <xhmikosr@gmail.com>
When using single-quotes in config.yml, the previous
regular expression in build/generate-cli.js wasn't working correctly,
it was replacing ALL string values with hashes.
Now both double- and single-quotes can be used in config.yml,
and the RegExp will work as expected.
I have tested the script with both
'
and"
used inconfig.yml
, and it seems to work properly!The changes to
config.yml
haven't been committed, though.Fixes #29741