-
-
Notifications
You must be signed in to change notification settings - Fork 6.4k
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
Restore old behavior for file:////foo/bar URLs #2438
Conversation
This may be a case where the correct behavior of curl on Unix and the correct behavior of curl on Windows are not actually the same thing. Firefox and Chrome handle this case differently on different operating systems. Both of them treat it as a local filesystem path on Unix and a UNC path on Windows. Although its not clear to me if this behavioral difference in Firefox and Chrome is something they explicitly implemented or if it is really just a difference in how Linux and Windows treat paths like |
This is going to make file:////foo/bar -> /foo/bar which in Windows I don't think is what you want, and I'm not sure that it's right for Unix either. How are you supposed to access shares via file: in Unix? |
You're right. The old windows behavior appears to be passing it as So actually there is a Windows regression here too right now. Before version 7.57.0, curl already handled UNC paths like And that also means my change to test2072 will fail on windows. Is there a way to make a test OS specific?
You're right, just like above it should just be passed to the OS as
Windows file shares? I think Appendix E.2.3 of RFC 8089 is really just explaining how Windows path resolution combines with |
I didn't see a way to flag tests as OS specific so I threw 2072 in the disabled list with a note saying it was OS specific behavior and that the test was for the Unix behavior. I don't have a Windows box set up to be able to build stuff like this. With this patch it should behave like it did before the changes in 7.57.0 and trigger SMB access on Windows again. |
@phluid61 could use your input |
I wanted it to be part of the specification. However updating such an ancient and underspecified scheme was already contentious enough, without making any outright changes -- so we're left with this gap. The informational appendix was my attempt at describing what seemed like the best chance for interoperability without actually writing any normative language; but that lack of normativity also meant it received less scrutiny (so more grains of salt are required along with it.) If/when IETF regains the energy and appetite for it, I'm confident a future version of the In terms of this particular PR, is this a correct summary of what gets passed to the OS to open()?
If so, it's fine with me. (I derived those bottom rows by reading the code. If that's how it actually works, then... 🤔) |
On Thu, Mar 29, 2018 at 10:23:12PM -0700, Jon DeVree wrote:
And that also means my change to test2072 will fail on windows. Is there a way
to make a test OS specific?
You can use an appropriate <precheck>. There aren't any existing ones for OS
detection, but perl is available so I'm sure there's a one-liner that would do
it.
|
Sorry, it was getting late and I didn't actually phrase that well. I meant to say that it was probably only intended to be implemented on platforms that already use Windows/UNC path resolution behavior. I don't know if that actually matches your intentions, but its what I intended to say. So curl on Windows should follow Appendix E.2.3 because that is how Windos path resolution works. Whereas curl on Unix should just follow Unix path resolution behavior instead. This OS dependent behavior is how Mozilla and Chrome appear to behave.
Yes. In fact I hadn't thought to try the ones with the explicit localhost, but that is how they behave. |
Thanks, I added a precheck based on the data in http://perldoc.perl.org/perlport.html#PLATFORMS |
lib/url.c
Outdated
* path, would have included a second slash. So if there are two | ||
* slashes, swallow one. | ||
* path, would have included a second slash. POSIX requires the OS to | ||
* handle leading double slashes (or triple or quadruple) so there is |
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.
curl builds on numerous not-quite-POSIX platforms as well so I don't think the phrasing should this "absolute" here.
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.
Is changing it from "there is no need" to "there should be no need" enough?
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.
I could just remove this entire giant comment block since there is no longer any actual code here implementing something. I guess the only reason I left it here was to include the comment about how stripping the extra slash would actually break Windows UNC paths.
lib/url.c
Outdated
* no need to do anything special here for this case. | ||
* | ||
* Swallowing the extra "/" will actually break the UNC path resolution | ||
* on Windows which is described in RFC 8089, Appendix E, Section E.2.3 |
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.
This looks like a typo. It should be section 3.2, right? The same mistake exists in the commit message.
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.
Yes, my mistake.
curl 7.57.0 and up interpret this according to Appendix E.3.2 of RFC 8089 but then returns an error saying this is unimplemented. This is actually a regression in behavior on both Windows and Unix. Before curl 7.57.0 this URL was treated as a path of "//foo/bar" and then passed to the relevant OS API. This means that the behavior of this case is actually OS dependent. The Unix path resolution rules say that the OS must handle swallowing the extra "/" and so this path is the same as "/foo/bar" The Windows path resolution rules say that this is a UNC path and automatically handles the SMB access for the program. So curl on Windows was already doing Appendix E.3.2 without any special code in curl.
Thanks! |
This is a fairly common thing to end up in scripts via constructions that do
things like: file:///${VAR}
curl allowed this prior to 7.57.0 but it was broken by adding "support"
for UNC paths as defined in Appendix E.3.2 of RFC 8089. This appendix is
non-normative though and curl does not actually support it beyond rejecting
them. (In fact curl does not support any flavor of remote file: URLs.)
Given the fact that curl does not actually implement support for UNC paths I think it would be better to restore the old behavior.