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

Label Generator is encoding the URL as a note, not a URL #564

Closed
5 tasks done
timdonovanuk opened this issue Oct 4, 2023 · 7 comments · Fixed by #618
Closed
5 tasks done

Label Generator is encoding the URL as a note, not a URL #564

timdonovanuk opened this issue Oct 4, 2023 · 7 comments · Fixed by #618
Labels
bug Something isn't working
Milestone

Comments

@timdonovanuk
Copy link

First Check

  • This is not a feature request
  • I added a very descriptive title to this issue.
  • I used the GitHub search to find a similar issue and didn't find it.
  • I searched the documentation, with the integrated search.
  • I already read the docs and didn't find an answer.

Homebox Version

https://homebox.fly.dev/reports/label-generator

What is the issue you are experiencing?

On my phone (samsung s23) it tries to open the URL's on that page as https%3A%2F%2Ftest.com%2Fa%2F000-001 so clearly something is wrong with encoding here.

How can the maintainer reproduce the issue?

Go to the demo site, open https://homebox.fly.dev/reports/label-generator, scan a QR code.

Deployment

Other

Deployment Details

No response

@timdonovanuk timdonovanuk added the bug Something isn't working label Oct 4, 2023
@avantegarde
Copy link

+1 I'm seeing this same behavior on the demo site along with my self hosted version. Both the label generator page as well as the qr codes being generated on individual item/asset pages are not encoded correctly.

@Smith3rman
Copy link

+1 I have the same problem on my side. The same problem happens in the Location QR-codes.

@bee-eater
Copy link
Contributor

bee-eater commented Oct 28, 2023

Same here! Anyone knows a quick fix?

@WoosterInitiative
Copy link

I'm happy to take a look at the code, but my biggest problem is always finding where in the code the thing is generated, specifically, what module generates the QR code? If someone can point me to it, I'm happy to take a crack at a PR; else, I just don't have the time to dig through all of the code.

@porteusconf
Copy link

I see backend/app/api/handlers/v1/v1_ctrl_qrcode.go imports go-qrcode from this git repo:
https://github.com/yeqown/go-qrcode which is active with only 5 issues at this time. So I may try to find out if the malformed URL is caused by go-qrcode or by homebox.

@jackwilsdon
Copy link

jackwilsdon commented Nov 12, 2023

It appears that the issue is caused by the /qrcode URL generated by the frontend having double URL-encoded parameters:

https://homebox.fly.dev/api/v1/qrcode?data=https%253A%252F%252Fhomebox.fly.dev%252Fa%252F000-001

Decoding the data parameter once gives:

https://homebox.fly.dev/api/v1/qrcode?data=https%3A%2F%2Fhomebox.fly.dev%2Fa%2F000-001

Scanning the latter works fine. From a cursory glance at the frontend code, the issue appears to be in 2 places (label and item pages):

return route(`/qrcode`, { data: encodeURIComponent(data) });

return route(`/qrcode`, { data: encodeURIComponent(currentURL) });

The data property probably shouldn't be URL-encoded here, as that is already handled in the route function:

export function route(rest: string, params: Record<string, QueryValue> = {}): string {
const url = new URL(parts.prefix + rest, parts.host);
for (const [key, value] of Object.entries(params)) {
if (Array.isArray(value)) {
for (const item of value) {
url.searchParams.append(key, String(item));
}
} else {
url.searchParams.append(key, String(value));
}
}
return url.toString().replace("http://localhost.com", "");
}

Using url.searchParams encodes the parameters automatically, so the additional encodeURIComponent isn't needed:

const url = new URL("https://homebox.fly.dev/api/v1/qrcode");
url.searchParams.append("data", "https://homebox.fly.dev/a/000-001");
console.log(url.toString()); // https://homebox.fly.dev/api/v1/qrcode?data=https%3A%2F%2Fhomebox.fly.dev%2Fa%2F000-001

@Triple-Z
Copy link

Triple-Z commented Nov 13, 2023

same problem here, hope to see it solved in the next version ❤️

@hay-kot hay-kot added this to the v0.10.2 milestone Nov 15, 2023
@hay-kot hay-kot closed this as completed Nov 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants