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

Allow to parse opam 2.1 switch import files containing extra-files #5943

Merged
merged 3 commits into from
May 8, 2024

Conversation

kit-ty-kate
Copy link
Member

@kit-ty-kate kit-ty-kate commented May 2, 2024

Fixes #5941

opam 2.1 used the Base64 module from extlib which does not seem to pad encoded outputs. In contrast, opam 2.2 uses the Base64 module from the base64 library (after extlib's Base64 module was removed in extlib.1.7.8) which by default pads outputs and requires padded inputs when decoding them.

cc-ing base64 implementations maintainers @dinosaure @ygrek

  • Question for @dinosaure: is this fix fine? Should Base64.encode be also called with ~pad:false? What are the pitfalls of disabling padding?

  • Question for @ygrek: Just to double-check, am i correct in assuming the output of extlib's base64 implementation is always not padded?

@dinosaure
Copy link

As far as Base64.decode_exn is concerned, the default setting is that values should have a pad as if there were a '\000' for a C string. Of course, in reality, this is not necessarily the case. The pad becomes useful if you concatenate base64 values and want to decode them cleanly without there being a mismatch between the values (since you have this pad as a delimiter).

If the base64 value exists on its own (or is delimited by something else such as "), the pad is not necessary. What Base64.decode_exn tries to do is check for the existence of this pad by default, but if you are manipulating base64 values where the pad is not needed, pad:false is indeed advisable.

In other words, pad:true is for a paranoid mode of retrieving values.

@kit-ty-kate
Copy link
Member Author

Thanks! In that case I will use this option for the encoder as well.
I'll also add some tests in a minute

@rjbou rjbou self-requested a review May 2, 2024 13:40
Copy link
Collaborator

@rjbou rjbou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tiny comment in the test (see commit), otherwise ltgm! Thanks!

opam 2.1 used the Base64 module from extlib which does not seem to pad encoded outputs.
In contrast, opam 2.2 uses the Base64 module from the base64 library
(after extlib's Base64 module was removed in extlib.1.7.8) which by default pads outputs
and requires padded inputs when decoding them
This restores the behaviour from opam < 2.2
@kit-ty-kate kit-ty-kate merged commit 5c4c1a4 into ocaml:master May 8, 2024
29 checks passed
@kit-ty-kate kit-ty-kate deleted the allow-unpadded-base64 branch May 8, 2024 10:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

import with opam 2.2 of an export file created with 2.1.2 fails
3 participants