-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
base64 validation too strict; padding is optional #1156
Comments
Fair enough, happy to take a PR if you're up for it. |
I am, as I just got hit with a bug on my end because I didn't apply the padding workaround in all the places that I was validating. :-/ Here's a direct link to the code in question Line 409 in 5450404
I'm going to fix the code on my end first then try to fix this. @Marsup do you feel it's better to arbitrarily pad and test or just use a different regex? |
I would vote for a new regex to test against based on the |
I'm cool with that. |
In looking at this, I would think that we would make some modifications to our RegExp to make the padding ( Definitely happy to take a look at a PR. |
This thread has been automatically locked due to inactivity. Please open a new issue for related bugs or questions following the new issue template instructions. |
Context
What are you trying to achieve or the steps to reproduce ?
Determine if a URL parameter contains valid base64 encoded content.
Example values:
MTYyMDcxMDozOjE
The problem is that the validation fails on a base64 string that is valid but does not have padding; the issue was dismissed in #1081
I don't agree with that interpretation; it's not invalid, it just doesn't have optional padding.
https://en.wikipedia.org/wiki/Base64#Output_Padding
The input is not normalized and comes from a variety of sources that I do not have direct control over and I cannot force changes, nor can I just arbitrarily ignore unpadded content.
Attempting to pad the content prior to validation is hacky.
A more graceful solution would be to make padding optional.
options
: - an optional object with the following optional keys:paddingRequired
: iftrue
, requires that the string include=
padding. Defaults totrue
.Which result you had ?
What did you expect ?
No errors.
The text was updated successfully, but these errors were encountered: