-
Notifications
You must be signed in to change notification settings - Fork 9
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
Trailing / for UnixFS directory normalization is missing #62
Comments
@achingbrain do you have specific article to reproduce? Check if this was also broken when loaded via dweb.link gateway. iirc this ancient wikipedia mirror has JS that fixes relative links post-load, so if that JS file failed to load via SW, links will be broken. |
Sure, I posted a bunch in #61 E.g. click any linked text here: https://bafybeiaysi4s6lnjev27ln5icwm6tueaw2vdykrtjkwiphwekaywqhcjze.ipfs.sw.sgtpooki.com/wiki/Archaeology
Ah, ok - there are some js errors in the console - a syntax error in the file, maybe that's it. Is there a later |
Ok, I know what is the problem. SW gateway does not normalize directory URLs. They must end with Example: This is not specific to Wikipedia, this is a bug on all UnixFS directories (with index.html) I suspect we need to fix this inside of verified-fetch because we need to know if the terminal element of content path is a directory. Support |
Why is this the case? I think we should be able to serve a directory with or without a trailing slash. My thinking is that it's not a requirement for apache/nginx/etc so people will author their websites with either style, plus forcing redirects for (potentially) every directory request is expensive. If this is necessary, a 301 would better so browsers don't re-request the invalid URL?
Unless I'm missing something we can detect this as we traverse the DAG - we need the terminal node to display the content, at which point we can interrogate the UnixFS metadata to find out if it's a directory or not, no need to guess from the path. |
Correct, if one only cares about their single website, loaded from a single URL, this does not matter. If we want to build a reliable ecosystem where people can publish in permissionless fashion, and we have 3 addressing schemes, we need to normalize, otherwise we end up with bugs like the one described in this issue. Trailing slash decides the anchor of relative links, and how things like service worker scoping works, has both practical and security ramifications. This is also to ensure relative links work the same way on legacy path gateways: We have it as explicit part of gateway specs and conformance tests for this very reason:
Added reasoning why we do this in ipfs/specs#464.
Yes, in go-ipfs code we made the decision to redirect after we've read terminal element, one important thing is to preserve any query params: And yes, we want 301 as the final one, just easier to test with 302 so I always start with that :) |
Related: ipfs/helia-verified-fetch#5 |
Quick update on the state of thingsTook Service worker gateway needs to convert What happensWith ipfs/helia-verified-fetch#5, resolving
Ideal stateI believe we should not spend time on temporary translation glue code in this project, instead spend time on implementing support for What we want:
I think we want to do this right, in a way that is future-proof. |
* chore: upgrade helia verified fetch * chore: note on manual redirects #62 (comment) --------- Co-authored-by: Daniel N <[email protected]> Co-authored-by: Marcin Rataj <[email protected]>
If the user does At the moment Tests to prevent regressions are at ipfs/helia-verified-fetch#15 |
this should be done, the verified-fetch version isn't updated in helia-service-gateway yet though? |
Just to confirm, @achingbrain this is in https://www.npmjs.com/package/@helia/verified-fetch 1.1.0? If so, we need to refactor this repo to pass original request URL (http(s)://) ps. ah, yes, ipfs/helia-verified-fetch#15 is adding test to guard the behavior we need, thanks! |
this will be fully resolved once #151 and ipfs/helia-verified-fetch#33 are merged and we update to the latest verified-fetch version |
Trying to click a footnote takes you back to the Wikipedia homepage instead of the footer of the current page:
This is because the footnote href is a relative link up one directory:
All local links seem to have this problem:
The text was updated successfully, but these errors were encountered: