Copilot commented on code in PR #50205:
URL: https://github.com/apache/arrow/pull/50205#discussion_r3427718413


##########
cpp/src/arrow/filesystem/s3fs.cc:
##########
@@ -3052,13 +3052,20 @@ Result<std::string> S3FileSystem::MakeUri(std::string 
path) const {
   if (path.length() <= 1 || path[0] != '/') {
     return Status::Invalid("MakeUri requires an absolute, non-root path, got 
", path);
   }
-  ARROW_ASSIGN_OR_RAISE(auto uri, util::UriFromAbsolutePath(path));
+  ARROW_ASSIGN_OR_RAISE(auto uri_from_path, util::UriFromAbsolutePath(path));
+  constexpr std::string_view kFileScheme = "file:///";
+  std::string_view uri_view(uri_from_path);
+  if (uri_view.starts_with(kFileScheme)) {
+    uri_view.remove_prefix(kFileScheme.size());
+  } else if (uri_view.starts_with("/")) {
+    // MinGW doesn't have `file:///` scheme, we just remove the leading slash
+    uri_view.remove_prefix(1);
+  }

Review Comment:
   `UriFromAbsolutePath()` can also return `file://<host>/...` for UNC-style 
paths on Windows (see util/uri_test.cc). Since `MakeUri()` currently accepts 
inputs like "//bucket/key" (it only checks `path[0] == '/'`), this code will 
generate an invalid URI like `s3://file://bucket/key...`. Consider also 
stripping the `file://` prefix (after checking `file:///`), or rejecting paths 
that begin with "//".



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to