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

Shared bean cant be read in anymore #876

Open
graphefruit opened this issue Jan 9, 2025 · 4 comments
Open

Shared bean cant be read in anymore #876

graphefruit opened this issue Jan 9, 2025 · 4 comments
Assignees
Labels

Comments

@graphefruit
Copy link
Owner

Thats due to somehow changes that "+" is replaced with " " (space)

@RagingCactus
Copy link
Collaborator

The (in my opinion) "proper" fix would be to use URL-safe Base64, where + is replaced by - and / is replaced by _.
It might be a good idea to use this in the future.

@graphefruit
Copy link
Owner Author

Thanks for the support.
The issue is that the URL is generated with PROTO-Buff, and I don't know if things could "crash" or don't work anymore

The strange thing is: The url is read correctly, but the URL-Params search is then destroying the "+" into a space, which wasn't before.

@RagingCactus
Copy link
Collaborator

RagingCactus commented Jan 10, 2025

The issue is that the URL is generated with PROTO-Buff, and I don't know if things could "crash" or don't work anymore

I'm not talking about the protobuf serialization step, but about the base64 encoding afterwards. I'm talking about line 123 in this example:

const bytes = BeanProto.encode(protoBean).finish();
const base64String = this.uiHelper.encode(bytes);

uiHelper.encode does "normal" Base64 encoding of the protobuf bytes, see here:

public encode(arrayBuffer) {
return btoa(String.fromCharCode(...new Uint8Array(arrayBuffer)));
}

Normal Base64 contains + and / characters, which need to be encoded if they are used in URLs. This is why normal Base64 is not considered to be "URL-safe". URL-safe Base64 replaces + with - and / with _, which do not have a special meaning in URLs.

I would propose to use the URL-safe Base64 alphabet instead to prevent other possible breakages in the future (which could be done using two simple .replace() calls). You never know how platforms URL-encode and/or URL-decode your shared URLs and in intent/deeplink handlers. You could keep the current workaround for backwards compatibility, but only generate URL-safe links in the future.

@graphefruit
Copy link
Owner Author

Fixed with 8.0.3 in the first place.

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

No branches or pull requests

2 participants