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

localstorage ALWAYS parses four letter data as if base64 #3391

Closed
DevWouter opened this issue Apr 9, 2024 · 2 comments
Closed

localstorage ALWAYS parses four letter data as if base64 #3391

DevWouter opened this issue Apr 9, 2024 · 2 comments
Labels
kind/bug Something isn't working stale

Comments

@DevWouter
Copy link

DevWouter commented Apr 9, 2024

Expected Behavior

When invoking create on localstorage with test I expect that the new file has 4 bytes which spell out "test".

Actual Behavior

The actual content of the file is 3 bytes 0xb5 0xeb 0x2d.

Steps to Reproduce the Problem

Invoke the following.

curl -d '{ "operation": "create", "data": "test" }' \
      http://localhost:<dapr-port>/v1.0/bindings/<binding-name>

Example taken from: https://docs.dapr.io/reference/components-reference/supported-bindings/localstorage/#create-file but with the data being replaced with "test"

Cause

Since other words like "hello" worked fine I did some additional research. The problem is this line https://github.com/dapr/components-contrib/blob/cfee998aba0817ae07dc31bb53c34d21f6b9f4f2/bindings/localstorage/localstorage.go#L172C1-L175C3

It assumes that any content can be encoded as base64 and if so it will convert it before saving. and four letter words can be base64 format.

If I replace test with dGVzdA== then the file contains the text "test".
If I replace test with YWFh then the file contains "aaa".

Additional remarks

When I did some testing using javascripts atob and btoa I noticed that I could convert it back and forth. Originally I assumed that the word "test" had a special meaning 😄

@DevWouter DevWouter added the kind/bug Something isn't working label Apr 9, 2024
Copy link

github-actions bot commented May 9, 2024

This issue has been automatically marked as stale because it has not had activity in the last 30 days. It will be closed in the next 7 days unless it is tagged (pinned, good first issue, help wanted or triaged/resolved) or other activity occurs. Thank you for your contributions.

@github-actions github-actions bot added the stale label May 9, 2024
Copy link

This issue has been automatically closed because it has not had activity in the last 37 days. If this issue is still valid, please ping a maintainer and ask them to label it as pinned, good first issue, help wanted or triaged/resolved. Thank you for your contributions.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale May 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Something isn't working stale
Projects
None yet
Development

No branches or pull requests

1 participant