-
Notifications
You must be signed in to change notification settings - Fork 71
Bugfix: whitespace in object name #178
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
Bugfix: whitespace in object name #178
Conversation
1e65f9f
to
3da3c6e
Compare
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.
Pull Request Overview
This PR fixes handling of object names containing whitespace or UTF-8 characters by switching to rand_object_name_utf8
, refactoring common test logic into helper functions, and updating URL encoding/decoding utilities and their usage throughout the S3 client.
- Replaced
rand_object_name
withrand_object_name_utf8
in tests and added tests for names with spaces. - Refactored repetitive test cases into generic
test_*
helper functions. - Introduced
url_decode
,url_decode_old
, andurl_encode
insrc/s3/utils.rs
and updated allurlencode
/urldecode
calls in the client. - Added form-based decoding logic (
url_decode_w_enc
) inlist_objects
response parsing.
Reviewed Changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 1 comment.
Show a summary per file
File | Description |
---|---|
tests/test_upload_download_object.rs | Use UTF-8–safe random names and whitespace test |
tests/test_object_delete.rs | Refactor delete tests and add whitespace case |
tests/test_object_copy.rs | Refactor copy tests and add whitespace case |
tests/test_list_objects.rs | Refactor list tests and add whitespace case |
tests/test_get_object.rs | Refactor get tests and add whitespace case |
tests/test_bucket_create_delete.rs | Refactor bucket tests and add whitespace case |
src/s3/utils.rs | Add url_decode_old , url_decode , url_encode |
src/s3/response/list_objects.rs | Swap to url_decode_w_enc and remove old decode |
src/s3/multimap.rs | Replace urlencode with url_encode |
src/s3/client/delete_bucket.rs | Early return when bucket doesn't exist |
src/s3/builders/put_object.rs | Replace urlencode with url_encode |
src/s3/builders/copy_object.rs | Replace urlencode with url_encode |
common/src/cleanup_guard.rs | Comment out debug output |
Comments suppressed due to low confidence (5)
tests/test_list_objects.rs:162
- [nitpick] The comment contains a typo: it should say
yielding "a+b%2Bc"
instead of"a+b2Bc"
, and clarify the clause about percent-decoding.
/// In percent-encoding, "a b+c" becomes "a%20b%2Bc", but some S3 implementations may do
src/s3/utils.rs:52
- [nitpick] Replace the
TODO
placeholder with a concise description of what this function does and when to use it.
/// Decodes a URL-encoded string, TODO
src/s3/utils.rs:57
- [nitpick] Provide details on whether this function performs percent-decoding or form-decoding and how it differs from
url_decode_old
.
/// Decodes a URL-encoded string, TODO
src/s3/utils.rs:65
- [nitpick] Clarify in the doc comment whether this uses percent-encoding and reference relevant RFC or behavior.
/// Encodes a string using URL encoding, TODO
src/s3/utils.rs:53
- Add unit tests for
url_decode_old
,url_decode
, andurl_encode
to verify correct handling of spaces, plus signs, and percent-encoded sequences.
pub fn url_decode_old(s: &str) -> Result<Cow<str>, FromUtf8Error> {
7222797
to
65fe09a
Compare
…nstead of Percent-decoding
65fe09a
to
58e9ae7
Compare
The url_decode function now correctly decodes "a+b%2Bc" into "a b+c" instead of the incorrect "a+b+c".
Every function that uses either url_encode or url_decode now has dedicated tests to ensure correct handling of whitespace.