-
Notifications
You must be signed in to change notification settings - Fork 42
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
Properly escape multi-segment path parameters #869
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #869 +/- ##
========================================
+ Coverage 8.00% 8.01% +0.01%
========================================
Files 258 258
Lines 64416 64427 +11
========================================
+ Hits 5155 5166 +11
Misses 58966 58966
Partials 295 295 ☔ View full report in Codecov by Sentry. |
@@ -109,6 +109,18 @@ func makeQueryString(data interface{}) (string, error) { | |||
return "", fmt.Errorf("unsupported query string data: %#v", data) | |||
} | |||
|
|||
func EncodeMultiSegmentPathParameter(p string) string { | |||
segments := strings.Split(p, "/") | |||
b := strings.Builder{} |
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 can be preallocated to at least len(p)
.
## Changes Ports databricks/databricks-sdk-go#869 to Python SDK. Subsumes #592. Currently, path parameters are directly interpolated into the request URL without escaping. This means that characters like /, ? and # will not be percent-encoded and will affect the semantics of the URL, starting a new path segment, query parameters, or fragment, respectively. This means that it is impossible for users of the Files API to upload/download objects that contain ? or # in their name. / is allowed in the path of the Files API, so it does not need to be escaped. The Files API is currently marked with x-databricks-multi-segment, indicating that it should be permitted to have / characters but other characters need to be percent-encoded. This PR implements this. ## Tests - [x] Unit test for multi-segment path escaping behavior. - [x] Updated integration test to use # and ? symbols in the file name. This failed on main but succeeded on this PR.
## Changes Ports databricks/databricks-sdk-go#869 to Java SDK. Currently, path parameters are directly interpolated into the request URL without escaping. This means that characters like `/`, `?` and `#` will not be percent-encoded and will affect the semantics of the URL, starting a new path segment, query parameters, or fragment, respectively. This means that it is impossible for users of the Files API to upload/download objects that contain `?` or `#` in their name. `/` is allowed in the path of the Files API, so it does not need to be escaped. The Files API is currently marked with `x-databricks-multi-segment`, indicating that it should be permitted to have `/` characters but other characters need to be percent-encoded. This PR implements this. ## Tests - [x] Unit test for multi-segment path escaping behavior. - [x] Updated integration test to use # and ? symbols in the file name.
## Changes Ports databricks/databricks-sdk-go#869 to Java SDK. Currently, path parameters are directly interpolated into the request URL without escaping. This means that characters like `/`, `?` and `#` will not be percent-encoded and will affect the semantics of the URL, starting a new path segment, query parameters, or fragment, respectively. This means that it is impossible for users of the Files API to upload/download objects that contain `?` or `#` in their name. `/` is allowed in the path of the Files API, so it does not need to be escaped. The Files API is currently marked with `x-databricks-multi-segment`, indicating that it should be permitted to have `/` characters but other characters need to be percent-encoded. This PR implements this. ## Tests - [x] Unit test for multi-segment path escaping behavior. - [x] Updated integration test to use # and ? symbols in the file name.
Changes
Currently, path parameters are directly interpolated into the request URL without escaping. This means that characters like
/
,?
and#
will not be percent-encoded and will affect the semantics of the URL, starting a new path segment, query parameters, or fragment, respectively. This means that it is impossible for users of the Files API to upload/download objects that contain?
or#
in their name./
is allowed in the path of the Files API, so it does not need to be escaped.The Files API is currently marked with
x-databricks-multi-segment
, indicating that it should be permitted to have/
characters but other characters need to be percent-encoded. This PR implements this.This PR builds on #868, correcting the test names for UC files.
Tests
#
and?
symbols in the file name. This failed onmain
but succeeded on this PR.