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

Use base64url instead of base64 to avoid escaping #57

Merged
merged 6 commits into from
Apr 4, 2022
Merged

Use base64url instead of base64 to avoid escaping #57

merged 6 commits into from
Apr 4, 2022

Conversation

fonsp
Copy link
Member

@fonsp fonsp commented Mar 7, 2022

PlutoSliderServer uses a lot of base64, for example, in a staterequest:

GET /staterequest/$notebook_hash/$bonds_data

We currently use the following as the Pluto hash:

  • sha1
  • then Base64 encoding
  • then URI escaping (e.g. Hello world => Hello%20world)

And for the bonds data, the same, but without hashing.

The hope was that by URI escaping, we would get legal URLs for base64 data, and additionally, in #29 , legal file names for precomputed states.

But! It turns out that some proxies and some file servers perform URI unescaping before it reaches this package. List of problems:

Solution

This PR uses the base64url algorithm instead of base64:

This function implements the base64url algorithm, which is like regular base64 but it produces legal URL/filenames: it uses - instead of +, _ instead of /, and it does not pad (with = originally).

See the wiki or the official spec (RFC 4648 §5).

TODO

TODO:

@fonsp fonsp merged commit 89aa456 into main Apr 4, 2022
@fonsp fonsp deleted the base64url branch April 4, 2022 14:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment