Skip to content

Commit e86ae27

Browse files
authored
[Storage] Fixed unable to create directory with only whiteSpaceChars (Azure#47592)
* Added fix + recording for File Shares * Added Changelog for File Share fix + added blobName whiteSpaceChar test cases
1 parent 6068422 commit e86ae27

File tree

8 files changed

+14
-4
lines changed

8 files changed

+14
-4
lines changed

sdk/storage/Azure.Storage.Blobs/assets.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
"AssetsRepo": "Azure/azure-sdk-assets",
33
"AssetsRepoPrefixPath": "net",
44
"TagPrefix": "net/storage/Azure.Storage.Blobs",
5-
"Tag": "net/storage/Azure.Storage.Blobs_4d91c5bf9c"
5+
"Tag": "net/storage/Azure.Storage.Blobs_f174db6035"
66
}

sdk/storage/Azure.Storage.Blobs/tests/ContainerClientTests.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3191,6 +3191,7 @@ await TestHelper.AssertExpectedExceptionAsync<RequestFailedException>(
31913191
[TestCase("%21%2A%27%28%29%3B%5B%5D%3A%40%26%25%3D%2B%24%2C%2F%3F%23äÄöÖüÜß")]
31923192
[TestCase("my cool blob")]
31933193
[TestCase("blob")]
3194+
[TestCase(" ")]
31943195
public async Task GetBlobClient_SpecialCharacters(string blobName)
31953196
{
31963197
// Arrange
@@ -3241,6 +3242,7 @@ public async Task GetBlobClient_SpecialCharacters(string blobName)
32413242
[TestCase("%21%2A%27%28%29%3B%5B%5D%3A%40%26%25%3D%2B%24%2C%2F%3F%23äÄöÖüÜß")]
32423243
[TestCase("my cool blob")]
32433244
[TestCase("blob")]
3245+
[TestCase(" ")]
32443246
public async Task GetBlobClients_SpecialCharacters(string blobName)
32453247
{
32463248
// Arrange

sdk/storage/Azure.Storage.Common/tests/Shared/TestExtensions.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using System.Globalization;
77
using System.Linq;
88
using System.Reflection;
9+
using System.Text;
910
using System.Threading.Tasks;
1011

1112
namespace Azure.Storage
@@ -216,13 +217,14 @@ private static string ToString(object credentials, bool exportSecrets)
216217
{
217218
if (credentials is StorageSharedKeyCredential sharedKeyCredentials)
218219
{
220+
string sanitizedBase64 = Convert.ToBase64String(Encoding.UTF8.GetBytes("Sanitized"));
219221
return string.Format(
220222
CultureInfo.InvariantCulture,
221223
"{0}={1};{2}={3}",
222224
Constants.ConnectionStrings.AccountNameSetting,
223225
sharedKeyCredentials.AccountName,
224226
Constants.ConnectionStrings.AccountKeySetting,
225-
exportSecrets ? ((StorageSharedKeyCredential)credentials).ExportBase64EncodedKey() : "Sanitized");
227+
exportSecrets ? ((StorageSharedKeyCredential)credentials).ExportBase64EncodedKey() : sanitizedBase64);
226228
}
227229
else if (credentials is SharedAccessSignatureCredentials sasCredentials)
228230
{

sdk/storage/Azure.Storage.Files.Shares/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
- ShareDirectoryClient.Create() and .CreateAsync()
1414
- ShareDirectoryClient.SetHttpHeaders() and .SetHttpHeadersAsync()
1515

16+
### Bugs Fixed
17+
- Fixed \[BUG\] Unable to create directory with only whiteSpaceChars #42891
18+
1619
## 12.21.0 (2024-11-12)
1720

1821
### Features Added

sdk/storage/Azure.Storage.Files.Shares/assets.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
"AssetsRepo": "Azure/azure-sdk-assets",
33
"AssetsRepoPrefixPath": "net",
44
"TagPrefix": "net/storage/Azure.Storage.Files.Shares",
5-
"Tag": "net/storage/Azure.Storage.Files.Shares_93074c2c0f"
5+
"Tag": "net/storage/Azure.Storage.Files.Shares_92c08b30c4"
66
}

sdk/storage/Azure.Storage.Files.Shares/src/ShareUriBuilder.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ private RequestUriBuilder BuildUri()
288288
if (!string.IsNullOrWhiteSpace(ShareName))
289289
{
290290
path.Append('/').Append(ShareName);
291-
if (!string.IsNullOrWhiteSpace(_directoryOrFilePath))
291+
if (!string.IsNullOrEmpty(_directoryOrFilePath))
292292
{
293293
path.Append('/').Append(_directoryOrFilePath.EscapePath());
294294
}

sdk/storage/Azure.Storage.Files.Shares/tests/DirectoryClientTests.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1997,6 +1997,7 @@ public async Task GetSubdirectoryAsync_NonAsciiName()
19971997
[TestCase("%21%27%28%29%3B%5B%5D", "%2B%24%2C%23äÄöÖüÜß%3B")]
19981998
[TestCase("directory", "my cool file")]
19991999
[TestCase("directory", "file")]
2000+
[TestCase(" ", " ")]
20002001
[RetryOnException(5, typeof(RequestFailedException))]
20012002
public async Task GetFileClient_SpecialCharacters(string directoryName, string fileName)
20022003
{
@@ -2061,6 +2062,7 @@ public async Task GetFileClient_SpecialCharacters(string directoryName, string f
20612062
[TestCase("%21%27%28", "%21%27%28%29%3B%5B%5D%40%26äÄöÖüÜß%3B")]
20622063
[TestCase("directory", "my cool directory")]
20632064
[TestCase("directory0", "directory1")]
2065+
[TestCase(" ", " ")]
20642066
public async Task GetSubDirectoryClient_SpecialCharacters(string directoryName, string subDirectoryName)
20652067
{
20662068
await using DisposingShare test = await GetTestShareAsync();

sdk/storage/Azure.Storage.Files.Shares/tests/ShareClientTests.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2288,6 +2288,7 @@ public async Task DeleteDirectoryAsync()
22882288
[TestCase("%21%27%28%29%3B%5B%5D%40%26%25%3D%2B%24%2C%23äÄöÖüÜß%3B")]
22892289
[TestCase("my cool directory")]
22902290
[TestCase("directory")]
2291+
[TestCase(" ")]
22912292
public async Task GetDirectoryClient_SpecialCharacters(string directoryName)
22922293
{
22932294
// Arrange

0 commit comments

Comments
 (0)