Skip to content

Conversation

HJLebbink
Copy link
Member

@HJLebbink HJLebbink commented Jul 10, 2025

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.

@HJLebbink HJLebbink requested a review from Copilot July 10, 2025 20:06
@HJLebbink HJLebbink added the bug Used in release doc generation label Jul 10, 2025
Copilot

This comment was marked as outdated.

@HJLebbink HJLebbink force-pushed the bugfix/whitespace-in-object-name branch 7 times, most recently from 1e65f9f to 3da3c6e Compare July 11, 2025 12:34
@HJLebbink HJLebbink requested a review from Copilot July 11, 2025 12:34
@HJLebbink HJLebbink marked this pull request as ready for review July 11, 2025 12:34
Copy link
Contributor

@Copilot Copilot AI left a 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 with rand_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, and url_encode in src/s3/utils.rs and updated all urlencode/urldecode calls in the client.
  • Added form-based decoding logic (url_decode_w_enc) in list_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, and url_encode to verify correct handling of spaces, plus signs, and percent-encoded sequences.
pub fn url_decode_old(s: &str) -> Result<Cow<str>, FromUtf8Error> {

@HJLebbink HJLebbink force-pushed the bugfix/whitespace-in-object-name branch 2 times, most recently from 7222797 to 65fe09a Compare July 11, 2025 12:49
@HJLebbink HJLebbink requested review from donatello and twuebi July 11, 2025 12:50
@donatello donatello merged commit 34b3e17 into minio:master Aug 11, 2025
6 checks passed
@HJLebbink HJLebbink deleted the bugfix/whitespace-in-object-name branch September 7, 2025 20:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Used in release doc generation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants