-
Notifications
You must be signed in to change notification settings - Fork 99
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
fix!: add escaped abspath header #434
Conversation
Codecov Report
@@ Coverage Diff @@
## main #434 +/- ##
==========================================
- Coverage 50.11% 48.86% -1.25%
==========================================
Files 249 246 -3
Lines 29998 29923 -75
==========================================
- Hits 15033 14622 -411
- Misses 13532 13874 +342
+ Partials 1433 1427 -6
|
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 after discussions with @aschmahmann about concerns of silent breaking changes and @hacdias about fixing this, we are gonna go with this solution for binary file names in the ipfs add
endpoint:
- leave current
abspath
header as-is, this header wont support binary encoded filepaths anymore due to the change in golang std; - add a new
abspath-percent
header that is exactly likeabspath
buturl.QueryEscape
ed, kubo will then prefer usingabspath-percent
if present but useabspath
if not - new clients will send both headers
This gives us this compatibility table:
New Client | Old Client | |
---|---|---|
New Server | Works fully through abspath-percent |
Binary file paths do not work |
Old Server | Works fully through abspath |
Works fully through abspath |
I don't know if headers are lazily or not decoded, so we might need to add an other response header indicating if abspath-percent
is supported and do a HEAD request to identify if we are talking to a new or old server.
a82f755
to
20859fa
Compare
Note that this will be more involved than initially planned. The current PR is not yet ready. We cannot send both headers at the same time. The My idea is to add a new argument to
In those 3 packages. My idea is to just fetch |
8d86569
to
40bed4c
Compare
Edit: this code does not do HTTP stuff, it just handles readers and writers, @hacdias options looks the least awful one that is still somewhat backward compatible. |
40bed4c
to
8101520
Compare
8101520
to
f483888
Compare
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.
LGTM
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.
Seems to be missing test for scenario with non-ASCII abspath
this PR is trying to fix?
(+ might be simplified – see comment inline, but that is fine to disregard)
48bddc0
to
5c4a00c
Compare
Fixed with separate tests with tags as per @Jorropo's suggestion. |
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.
The tests look hairy, but acceptable given this header is only used for experimental filestore feature in Kubo. We will have to revisit code related to --nocopy
at some point anyway.
Small nit inline but lgtm.
8308465
to
dfc4949
Compare
@Jorropo @lidel we need to release this before we bubble up to ipfs/go-ipfs-api#305 and ipfs/go-ipfs-cmds#243 so we don't have commit tags. Only when those two are merged can we also update Kubo. |
See ipfs/kubo#10065 and golang/go#60674.
Problem: we used to send binary data in
abspath
header when sending multipart requests. This is not compliant to the RFC but used to be allowed by Go (see linked issue). It is no longer possible to read multipart requests with binary data on their headers from Go 1.20.Solution: add a new header with the encoded version of the
abspath
. Unfortunately, we cannot send both the old and the new header, as Go 1.20 parses all headers when reading the multipart "part" and immediately fails. Therefore, we have to be careful. In this PR, we add an option toNewMultiFileReader
: this option will tell which header to use. See code for more details.