-
Notifications
You must be signed in to change notification settings - Fork 14
fix: signed URLs containing a hash #415
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
Conversation
c3fbd9e to
2d44993
Compare
|
@rhafer I thought I'd give this a shot, not sure if it's the best approach though. Also maybe there's a better utility method for encoding hashes? I think fully encoding the URL (including all slashes etc.) might be a bit too much. |
Thanks for looking into this. I think just replacing the Provided that the |
2d44993 to
246fe8c
Compare
The |
| for i := range pathParts { | ||
| pathParts[i] = url.PathEscape(pathParts[i]) | ||
| } | ||
| encodedPath := strings.Join(pathParts, "/") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
instead of the loop and the strings.Join I'd suggest to use:
encodedPath, err := url.JoinPath("", parts...)
That does the whole thing in one go.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Almost, it loses the leading /. I changed it to url.JoinPath("/", parts...). Which results in it always including a leading /, even if the given path doesn't have it initially. Which would probably not be an issue...? Or do you think it's better to check for that as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When do you get a leading /? Does that ever happen?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In my observations, the given path always has a leading /. So it just stays this way. But if there would be a path without it, encodedPath would still end up with a leading / now. But again, that doesn't seem to happen, at least not that I can see.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok. Then your change should be fine.
Encodes singed URLs so they can be resolved properly.
246fe8c to
4545dd5
Compare
Encodes singed URLs so they can be resolved properly.
fixes opencloud-eu/opencloud#1808