Fix: trim prefix slash in ListObjectVersionsHandler (#7919)
* Fix: trim prefix slash in ListObjectVersionsHandler * Add test for ListObjectVersions prefix handling Test validates that prefix normalization works correctly with and without leading slashes, ensuring the fix for /Veeam/Archive/ style prefixes. * Simplify prefix test to validate normalization logic The test now validates that the prefix normalization (TrimPrefix) works correctly and that normalized prefixes match paths as expected. This is a focused unit test that validates the core fix without requiring complex mocking of the filer client. * Enhance prefix test with full matchesPrefixFilter logic Added test cases for directory traversal including: - Directory matching with trailing slash - canDescend logic for recursive directory search - Full simulation of matchesPrefixFilter behavior This provides more comprehensive coverage of the prefix normalization fix and ensures it works correctly for both files and directories.
This commit is contained in:
@@ -985,7 +985,7 @@ func (s3a *S3ApiServer) ListObjectVersionsHandler(w http.ResponseWriter, r *http
|
||||
// Parse query parameters
|
||||
query := r.URL.Query()
|
||||
originalPrefix := query.Get("prefix") // Keep original prefix for response
|
||||
prefix := originalPrefix // Use for internal processing
|
||||
prefix := strings.TrimPrefix(originalPrefix, "/")
|
||||
// Note: prefix is used for filtering relative to bucket root, so no leading slash needed
|
||||
|
||||
keyMarker := query.Get("key-marker")
|
||||
|
||||
Reference in New Issue
Block a user