-
-
Notifications
You must be signed in to change notification settings - Fork 798
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
Allow "optional-padding" for Base64Variant
#500
Comments
This might be something for new contributors to tackle -- I can help as necessary. |
I think I can take a shot at this.
I'll take a deeper look into the wikipedia article to understand more. |
@pavan-kalyan Yes, I think I think starting with new method (and internal settings needed), implementation would be a good step: can then think about second aspect separately (can file a new issue if need be). |
I wanted to get a better idea on the invalid combination you mentioned because the API design would need to not let the user setup an invalid combination. Considering usesPadding and lenientPadding as internal settings in Base64Variant, the following table is meant to explain how encoding and decoding would work.
which of the above would be the invalid combination, the 3rd one? |
Hmmh. Spelled out like that, I wonder if there are more combinations -- leniency/non-leniency is not quite the same as required/not-allowed. Seems to me that instead of "lenient"/"strict" we have for reads
which would either mean two bits for reading (accept / require), or use of If so, existing setting of Besides this, we'd need new "mutant factory" method(s) ( Not sure if we should also add new variant(s) or not. |
Those are good ideas, I'll need to ponder on them and check for possible downsides for each. Regarding adding new variants, what is the main benefit of adding a new variant? It would be easier to use right? so users wouldn't have to set internal settings, but it could lead a huge set of additional variants being added for all possible permutations of settings (assuming those permutations have a valid use case, which is a little hard to predict). |
Correct: new variant would be mostly for convenience, and yes, number of permutations for all possibilities would be problematic. |
withPaddingRequired()/withPaddingAllowed()/ withPaddingForbidden() seem to be the most readable option.
because it would determine the signature and usage of the methods. |
I would think chaining would usually be used like
I specifically do not want to make |
The different reading behaviors require another constructor where the reading behaviour can be set, regardless of usesPadding/usesPaddingOnWriting. could you elaborate on the default for existing constructors? I'm assuming existing constructors' signature should not be modified? |
@pavan-kalyan Addition of new constructors would be needed yes, and expected. Existing constructors should be left for compatibility reasons, although may be deprecated if that makes sense (for eventual removal from 3.0). I do not remember exact details of current set up but I think it is rigidly keeping settings so that if padding is used on writing, it must be found on reading too. |
optional-padding
for Base64Variant
Base64Variant
(note: follow-up from FasterXML/jackson-databind#2183)
Currently
Base64Variant
instances either require use of specific padding character (and use it for output) or disable use of padding completely (neither written nor accepted).But it seems that sometimes a more lenient variant would make sense: one that
It seems best to add a "mutant factory" method in
Base64Variant
instance (something likewithLenientPadding(boolean)
maybe?). Whether additional entries should be addedBase64Variants
is an open question.We'll have to figure out what to do wrt existing "usePadding()" compared to new option; API may be cumbersome if we have 2 booleans but just 3 legal combinations.
Note that we may also change API for configuration for Jackson 3.x, later on.
The text was updated successfully, but these errors were encountered: