Skip to content
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

Fix objects with spaces in name not returned correctly fixes #1100 #1101

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 88 additions & 0 deletions Minio.Functional.Tests/FunctionalTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5292,6 +5292,94 @@ internal static async Task ListObjects_Test6(IMinioClient minio)
}
}

internal static async Task ListObjects_Test7(IMinioClient minio)
{
var startTime = DateTime.Now;
var bucketName = GetRandomName(15);
var prefix = "minix ";
var objectName = prefix + GetRandomName(10);
var args = new Dictionary<string, string>
(StringComparer.Ordinal)
{
{ "bucketName", bucketName },
{ "objectName", objectName },
{ "prefix", prefix },
{ "recursive", "false" }
};
try
{
await Setup_Test(minio, bucketName).ConfigureAwait(false);
var tasks = new Task[2];
for (var i = 0; i < 2; i++)
tasks[i] = PutObject_Task(minio, bucketName, objectName + i, null, null, 0, null,
rsg.GenerateStreamFromSeed(1));

await Task.WhenAll(tasks).ConfigureAwait(false);

await ListObjects_Test(minio, bucketName, prefix, 2, false).ConfigureAwait(false);
new MintLogger("ListObjects_Test7", listObjectsSignature,
"Tests whether ListObjects lists all objects matching a prefix with a space non-recursive",
TestStatus.PASS,
DateTime.Now - startTime, args: args).Log();
}
catch (Exception ex)
{
new MintLogger("ListObjects_Test7", listObjectsSignature,
"Tests whether ListObjects lists all objects matching a prefix with a space non-recursive",
TestStatus.FAIL,
DateTime.Now - startTime, ex.Message, ex.ToString(), args: args).Log();
throw;
}
finally
{
await TearDown(minio, bucketName).ConfigureAwait(false);
}
}

internal static async Task ListObjects_Test8(IMinioClient minio)
{
var startTime = DateTime.Now;
var bucketName = GetRandomName(15);
var prefix = "minix+";
var objectName = prefix + GetRandomName(10);
var args = new Dictionary<string, string>
(StringComparer.Ordinal)
{
{ "bucketName", bucketName },
{ "objectName", objectName },
{ "prefix", prefix },
{ "recursive", "false" }
};
try
{
await Setup_Test(minio, bucketName).ConfigureAwait(false);
var tasks = new Task[2];
for (var i = 0; i < 2; i++)
tasks[i] = PutObject_Task(minio, bucketName, objectName + i, null, null, 0, null,
rsg.GenerateStreamFromSeed(1));

await Task.WhenAll(tasks).ConfigureAwait(false);

await ListObjects_Test(minio, bucketName, prefix, 2, false).ConfigureAwait(false);
new MintLogger("ListObjects_Test8", listObjectsSignature,
"Tests whether ListObjects lists all objects matching a prefix with a plus non-recursive",
TestStatus.PASS,
DateTime.Now - startTime, args: args).Log();
}
catch (Exception ex)
{
new MintLogger("ListObjects_Test8", listObjectsSignature,
"Tests whether ListObjects lists all objects matching a prefix with a plus non-recursive",
TestStatus.FAIL,
DateTime.Now - startTime, ex.Message, ex.ToString(), args: args).Log();
throw;
}
finally
{
await TearDown(minio, bucketName).ConfigureAwait(false);
}
}

internal static async Task ListObjectVersions_Test1(IMinioClient minio)
{
var startTime = DateTime.Now;
Expand Down
2 changes: 2 additions & 0 deletions Minio.Functional.Tests/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,8 @@ public static async Task Main(string[] args)
functionalTestTasks.Add(FunctionalTest.ListObjects_Test4(minioClient));
functionalTestTasks.Add(FunctionalTest.ListObjects_Test5(minioClient));
functionalTestTasks.Add(FunctionalTest.ListObjects_Test6(minioClient));
functionalTestTasks.Add(FunctionalTest.ListObjects_Test7(minioClient));
functionalTestTasks.Add(FunctionalTest.ListObjects_Test8(minioClient));

// Test RemoveObjectAsync function
functionalTestTasks.Add(FunctionalTest.RemoveObject_Test1(minioClient));
Expand Down
3 changes: 2 additions & 1 deletion Minio/ApiEndpoints/BucketOperations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
using System.Net;
using System.Reactive.Linq;
using System.Runtime.CompilerServices;
using System.Web;
using System.Xml.Linq;
using CommunityToolkit.HighPerformance;
using Minio.ApiEndpoints;
Expand Down Expand Up @@ -271,7 +272,7 @@ public async IAsyncEnumerable<Item> ListObjectsEnumAsync(ListObjectsArgs args,

var objectKey = t.Element(ns + "Key")?.Value;
if (objectKey != null)
objectKey = Uri.UnescapeDataString(objectKey);
objectKey = HttpUtility.UrlDecode(objectKey);

return new Item
{
Expand Down
Loading