Skip to content
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

blob/fileblob: ignore URL's Host and drop leading / on Windows #644

Merged
merged 6 commits into from
Nov 7, 2018

Conversation

vangent
Copy link
Contributor

@vangent vangent commented Nov 7, 2018

This appears to be more correct than including the Host as part of the string we pass OpenBucket, based on my reading of https://en.wikipedia.org/wiki/File_URI_scheme. Dealing with file-based URLs in Windows is pretty hokey, but it's clear you have to drop the leading "/".

blob/example_test.go passes on Windows after these changes.

@googlebot googlebot added the cla: yes Google CLA has been signed! label Nov 7, 2018
@vangent vangent requested a review from shantuo November 7, 2018 19:22
// Host field, so URLs should always start with "file:///". On
// Windows, the leading "/" will be stripped, so "file:///c:/foo"
// will refer to c:/foo.
urlpath := url.PathEscape(filepath.ToSlash(dir))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we handle converting separators to '/' in package fileblob instead of letting user to it? Is "c:\foo\bar" invalid?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No; according to this, even on Windows, URLs referring to files should use "/" as a path separator. So doing this on the user side is correct.

That said, it might work either way; i.e., if they pass file:///c:\foo\bar.txt, it might work. "" is definitely illegal in the host part, which is why the test was failing before, but it might be legal in the path part, and we are just passing the path through to OpenBucket. I don't want to document it as working though., and the example should do the correct thing.

@shantuo shantuo assigned vangent and unassigned shantuo Nov 7, 2018
@vangent vangent assigned shantuo and unassigned vangent Nov 7, 2018
@vangent
Copy link
Contributor Author

vangent commented Nov 7, 2018

#323

@shantuo shantuo assigned vangent and unassigned shantuo Nov 7, 2018
@vangent vangent merged commit 9b197f2 into google:master Nov 7, 2018
@vangent vangent deleted the escapequery branch November 7, 2018 23:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes Google CLA has been signed!
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants