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

Base64 URL Safe Implementation #1862

Open
microalps opened this issue Dec 3, 2024 · 4 comments · May be fixed by #1921
Open

Base64 URL Safe Implementation #1862

microalps opened this issue Dec 3, 2024 · 4 comments · May be fixed by #1921

Comments

@microalps
Copy link

microalps commented Dec 3, 2024

Base64 filters were added in Liquid 5.1 together with URL safe variants. There seems to be two variants out in the wild, and the question is can/should Liquid support both? base64_url_safe_decode supports both. base64_url_safe_encode does not.

  1. Ruby's implementation swaps + and / only
  2. Microsoft's implementations (Microsoft.IdentityModel.Tokens, System.Buffers.Text of .NET9) also remove the = padding.

RFC 4648

The pad character "=" is typically percent-encoded when used in an URI, but if the data length is known implicitly, this can be avoided by skipping the padding

Mozilla defines it as

A common variant is "Base64 URL safe", which omits the padding and replaces +/

Related to dotliquid#542

@microalps
Copy link
Author

@dinsley @gmalette Do you have any insight on this?

@gmalette
Copy link
Contributor

gmalette commented Jan 6, 2025

I don't have insight on this

@sebastienros
Copy link

Adding that even the documentation that Shopify is pointing to mentions the padding should be omitted.

# Encodes a string to URL-safe [Base64 format](https://developer.mozilla.org/en-US/docs/Glossary/Base64).

@sebastienros sebastienros linked a pull request Feb 27, 2025 that will close this issue
@sebastienros
Copy link

I tried to create a PR to fix this issue

#1921

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants