-
Notifications
You must be signed in to change notification settings - Fork 124
fix: handling special characters #5451
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
base: master
Are you sure you want to change the base?
Conversation
This comment was marked as resolved.
This comment was marked as resolved.
b0effcf to
cc9f253
Compare
35ff8ec to
e7e657e
Compare
imports reordered too
e7e657e to
95e6938
Compare
95e6938 to
a0f9a30
Compare
a0f9a30 to
5df898e
Compare
| log.Error().Str("func", "PUTFile").Str("url", finalurl).Str("err", err.Error()).Msg("can't get a new location for a redirection") | ||
| return err | ||
| } | ||
| // FIXME: remove once the URL from 'Location' is properly encoded (with EOS 5.4) |
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.
so can we remove this now, since the fix is in homedev?
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.
it depends on how fast the new version of eos is going to production, my suggestion would be to merge this and add the removal to the eos5.4 branch
| encodedParentPath := url.PathEscape(parent.Path) | ||
| encodedMdPath := url.PathEscape(md.Path) | ||
| encodedRelativePath := strings.TrimPrefix(encodedMdPath, encodedParentPath) | ||
| _, err = url.PathUnescape(encodedRelativePath) |
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.
what's the point of doing this if you don't use the result?
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.
to check if the URL is still valid after these operations, splitting the unescaping the encodedRelativePath and href in two separate lines.
this intends to have a more precise error message instead of doing all the operations in the same line.
but it shouldn't be a problem to remove this and deal only with the href, err = url.PathUnescape(href) later.
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.
that might be a bit cleaner, in principle it works anyway so we should never see those messages, and if this ever needs to be debugged because something breaks they can just split the steps then
| return nil, errors.Wrapf(err, "failed to calculate path relative to parent: %v", md.Path) | ||
| } | ||
| href, err = url.JoinPath(hrefBase, relativePath) | ||
| href = url.PathEscape(hrefBase) + encodedRelativePath |
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.
take a look at https://pkg.go.dev/net/url#URL.ResolveReference for this
jessegeens
left a comment
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.
See comments
Some parts of this PR are a workaround while there isn't a fix in EOS for path encoding.
These can be reverted once there is one.
There is still a known issue with the character % (which should also be solved with the fix)