diff --git a/sdk/storage/azure-storage-blobs/CHANGELOG.md b/sdk/storage/azure-storage-blobs/CHANGELOG.md index a171d704c..3cc44e419 100644 --- a/sdk/storage/azure-storage-blobs/CHANGELOG.md +++ b/sdk/storage/azure-storage-blobs/CHANGELOG.md @@ -1,5 +1,11 @@ # Release History +## 1.0.0-beta.4 + +### Bug Fixes + +* Unencoded Container/Blob name is now encoded. + ## 1.0.0-beta.3 (2020-10-13) ### New Features diff --git a/sdk/storage/azure-storage-blobs/version.txt b/sdk/storage/azure-storage-blobs/version.txt index ffddd24fa..4740ad788 100644 --- a/sdk/storage/azure-storage-blobs/version.txt +++ b/sdk/storage/azure-storage-blobs/version.txt @@ -1 +1 @@ -1.0.0-beta.3 \ No newline at end of file +1.0.0-beta.4 \ No newline at end of file diff --git a/sdk/storage/azure-storage-files-datalake/CHANGELOG.md b/sdk/storage/azure-storage-files-datalake/CHANGELOG.md index e22102557..d3741d5fc 100644 --- a/sdk/storage/azure-storage-files-datalake/CHANGELOG.md +++ b/sdk/storage/azure-storage-files-datalake/CHANGELOG.md @@ -1,5 +1,11 @@ # Release History +## 1.0.0-beta.4 + +### Bug Fixes + +* Unencoded FileSystem/File/Path/Directory name is now encoded. + ## 1.0.0-beta.3 (2020-10-13) ### New Features diff --git a/sdk/storage/azure-storage-files-datalake/src/datalake_directory_client.cpp b/sdk/storage/azure-storage-files-datalake/src/datalake_directory_client.cpp index 2296af1c7..e87980c82 100644 --- a/sdk/storage/azure-storage-files-datalake/src/datalake_directory_client.cpp +++ b/sdk/storage/azure-storage-files-datalake/src/datalake_directory_client.cpp @@ -28,8 +28,8 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake { { auto parsedConnectionString = Azure::Storage::Details::ParseConnectionString(connectionString); auto directoryUri = std::move(parsedConnectionString.DataLakeServiceUri); - directoryUri.AppendPath(fileSystemName); - directoryUri.AppendPath(path); + directoryUri.AppendPath(Storage::Details::UrlEncodePath(fileSystemName)); + directoryUri.AppendPath(Storage::Details::UrlEncodePath(path)); if (parsedConnectionString.KeyCredential) { @@ -132,9 +132,9 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake { FileClient DirectoryClient::GetFileClient(const std::string& path) const { auto builder = m_dfsUri; - builder.AppendPath(path); + builder.AppendPath(Storage::Details::UrlEncodePath(path)); auto blobClient = m_blobClient; - blobClient.m_blobUrl.AppendPath(path); + blobClient.m_blobUrl.AppendPath(Storage::Details::UrlEncodePath(path)); auto blockBlobClient = blobClient.GetBlockBlobClient(); return FileClient( std::move(builder), std::move(blobClient), std::move(blockBlobClient), m_pipeline); @@ -143,9 +143,9 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake { DirectoryClient DirectoryClient::GetSubDirectoryClient(const std::string& path) const { auto builder = m_dfsUri; - builder.AppendPath(path); + builder.AppendPath(Storage::Details::UrlEncodePath(path)); auto blobClient = m_blobClient; - blobClient.m_blobUrl.AppendPath(path); + blobClient.m_blobUrl.AppendPath(Storage::Details::UrlEncodePath(path)); return DirectoryClient(std::move(builder), std::move(blobClient), m_pipeline); } diff --git a/sdk/storage/azure-storage-files-datalake/src/datalake_file_client.cpp b/sdk/storage/azure-storage-files-datalake/src/datalake_file_client.cpp index d7273e183..720e41997 100644 --- a/sdk/storage/azure-storage-files-datalake/src/datalake_file_client.cpp +++ b/sdk/storage/azure-storage-files-datalake/src/datalake_file_client.cpp @@ -106,8 +106,8 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake { { auto parsedConnectionString = Azure::Storage::Details::ParseConnectionString(connectionString); auto fileUri = std::move(parsedConnectionString.DataLakeServiceUri); - fileUri.AppendPath(fileSystemName); - fileUri.AppendPath(filePath); + fileUri.AppendPath(Storage::Details::UrlEncodePath(fileSystemName)); + fileUri.AppendPath(Storage::Details::UrlEncodePath(filePath)); if (parsedConnectionString.KeyCredential) { diff --git a/sdk/storage/azure-storage-files-datalake/src/datalake_file_system_client.cpp b/sdk/storage/azure-storage-files-datalake/src/datalake_file_system_client.cpp index d5e2caa4d..dc4d5c813 100644 --- a/sdk/storage/azure-storage-files-datalake/src/datalake_file_system_client.cpp +++ b/sdk/storage/azure-storage-files-datalake/src/datalake_file_system_client.cpp @@ -46,7 +46,7 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake { { auto parsedConnectionString = Azure::Storage::Details::ParseConnectionString(connectionString); auto fileSystemUri = std::move(parsedConnectionString.DataLakeServiceUri); - fileSystemUri.AppendPath(fileSystemName); + fileSystemUri.AppendPath(Storage::Details::UrlEncodePath(fileSystemName)); if (parsedConnectionString.KeyCredential) { @@ -163,7 +163,7 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake { PathClient FileSystemClient::GetPathClient(const std::string& path) const { auto builder = m_dfsUri; - builder.AppendPath(path); + builder.AppendPath(Storage::Details::UrlEncodePath(path)); return PathClient(builder, m_blobContainerClient.GetBlobClient(path), m_pipeline); } @@ -171,7 +171,7 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake { { auto builder = m_dfsUri; - builder.AppendPath(path); + builder.AppendPath(Storage::Details::UrlEncodePath(path)); auto blobClient = m_blobContainerClient.GetBlobClient(path); auto blockBlobClient = blobClient.GetBlockBlobClient(); return FileClient( @@ -181,7 +181,7 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake { DirectoryClient FileSystemClient::GetDirectoryClient(const std::string& path) const { auto builder = m_dfsUri; - builder.AppendPath(path); + builder.AppendPath(Storage::Details::UrlEncodePath(path)); return DirectoryClient(builder, m_blobContainerClient.GetBlobClient(path), m_pipeline); } diff --git a/sdk/storage/azure-storage-files-datalake/src/datalake_path_client.cpp b/sdk/storage/azure-storage-files-datalake/src/datalake_path_client.cpp index e4d3fd5aa..75a8ee7b0 100644 --- a/sdk/storage/azure-storage-files-datalake/src/datalake_path_client.cpp +++ b/sdk/storage/azure-storage-files-datalake/src/datalake_path_client.cpp @@ -90,8 +90,8 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake { { auto parsedConnectionString = Azure::Storage::Details::ParseConnectionString(connectionString); auto pathUri = std::move(parsedConnectionString.DataLakeServiceUri); - pathUri.AppendPath(fileSystemName); - pathUri.AppendPath(path); + pathUri.AppendPath(Storage::Details::UrlEncodePath(fileSystemName)); + pathUri.AppendPath(Storage::Details::UrlEncodePath(path)); if (parsedConnectionString.KeyCredential) { diff --git a/sdk/storage/azure-storage-files-datalake/src/datalake_service_client.cpp b/sdk/storage/azure-storage-files-datalake/src/datalake_service_client.cpp index 5d14308ad..642a2c1d8 100644 --- a/sdk/storage/azure-storage-files-datalake/src/datalake_service_client.cpp +++ b/sdk/storage/azure-storage-files-datalake/src/datalake_service_client.cpp @@ -164,7 +164,7 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake { FileSystemClient ServiceClient::GetFileSystemClient(const std::string& fileSystemName) const { auto builder = m_dfsUri; - builder.AppendPath(fileSystemName); + builder.AppendPath(Storage::Details::UrlEncodePath(fileSystemName)); return FileSystemClient( builder, m_blobServiceClient.GetBlobContainerClient(fileSystemName), m_pipeline); } @@ -179,8 +179,8 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake { blobOptions.MaxResults = options.MaxResults; auto result = m_blobServiceClient.ListBlobContainersSegment(blobOptions); auto response = ListFileSystemsSegmentResult(); - response.ContinuationToken - = result->ContinuationToken.empty() ? response.ContinuationToken : result->ContinuationToken; + response.ContinuationToken = result->ContinuationToken.empty() ? response.ContinuationToken + : result->ContinuationToken; response.Filesystems = FileSystemsFromContainerItems(result->Items); return Azure::Core::Response( std::move(response), result.ExtractRawResponse()); diff --git a/sdk/storage/azure-storage-files-datalake/test/datalake_file_system_client_test.cpp b/sdk/storage/azure-storage-files-datalake/test/datalake_file_system_client_test.cpp index 7b1e55c7b..d8aab550f 100644 --- a/sdk/storage/azure-storage-files-datalake/test/datalake_file_system_client_test.cpp +++ b/sdk/storage/azure-storage-files-datalake/test/datalake_file_system_client_test.cpp @@ -2,6 +2,7 @@ // SPDX-License-Identifier: MIT #include "datalake_file_system_client_test.hpp" +#include "azure/storage/common/crypt.hpp" #include "azure/storage/files/datalake/datalake_options.hpp" #include @@ -249,4 +250,36 @@ namespace Azure { namespace Storage { namespace Test { EXPECT_LE(2U, response->Paths.size()); } } + + TEST_F(DataLakeFileSystemClientTest, UnencodedPathDirectoryFileNameWorks) + { + const std::string non_ascii_word = "\xE6\xB5\x8B\xE8\xAF\x95"; + const std::string encoded_non_ascii_word = "%E6%B5%8B%E8%AF%95"; + std::string baseName = "a b c / !@#$%^&*(?/<>,.;:'\"[]{}|`~\\) def" + non_ascii_word; + { + std::string pathName = baseName + RandomString(); + auto pathClient = m_fileSystemClient->GetPathClient(pathName); + EXPECT_NO_THROW(pathClient.Create(Files::DataLake::PathResourceType::File)); + auto pathUrl = pathClient.GetUri(); + EXPECT_EQ( + pathUrl, m_fileSystemClient->GetUri() + "/" + Storage::Details::UrlEncodePath(pathName)); + } + { + std::string directoryName = baseName + RandomString(); + auto directoryClient = m_fileSystemClient->GetDirectoryClient(directoryName); + EXPECT_NO_THROW(directoryClient.Create()); + auto directoryUrl = directoryClient.GetUri(); + EXPECT_EQ( + directoryUrl, + m_fileSystemClient->GetUri() + "/" + Storage::Details::UrlEncodePath(directoryName)); + } + { + std::string fileName = baseName + RandomString(); + auto fileClient = m_fileSystemClient->GetFileClient(fileName); + EXPECT_NO_THROW(fileClient.Create()); + auto fileUrl = fileClient.GetUri(); + EXPECT_EQ( + fileUrl, m_fileSystemClient->GetUri() + "/" + Storage::Details::UrlEncodePath(fileName)); + } + } }}} // namespace Azure::Storage::Test diff --git a/sdk/storage/azure-storage-files-datalake/version.txt b/sdk/storage/azure-storage-files-datalake/version.txt index ffddd24fa..4740ad788 100644 --- a/sdk/storage/azure-storage-files-datalake/version.txt +++ b/sdk/storage/azure-storage-files-datalake/version.txt @@ -1 +1 @@ -1.0.0-beta.3 \ No newline at end of file +1.0.0-beta.4 \ No newline at end of file diff --git a/sdk/storage/azure-storage-files-shares/CHANGELOG.md b/sdk/storage/azure-storage-files-shares/CHANGELOG.md index b6909cd30..43bb51906 100644 --- a/sdk/storage/azure-storage-files-shares/CHANGELOG.md +++ b/sdk/storage/azure-storage-files-shares/CHANGELOG.md @@ -1,5 +1,11 @@ # Release History +## 1.0.0-beta.4 + +### Bug Fixes + +* Unencoded Share/File/Directory name is now encoded. + ## 1.0.0-beta.3 (2020-10-13) ### New Features diff --git a/sdk/storage/azure-storage-files-shares/src/share_client.cpp b/sdk/storage/azure-storage-files-shares/src/share_client.cpp index 7915cc939..a598c3760 100644 --- a/sdk/storage/azure-storage-files-shares/src/share_client.cpp +++ b/sdk/storage/azure-storage-files-shares/src/share_client.cpp @@ -24,7 +24,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { { auto parsedConnectionString = Azure::Storage::Details::ParseConnectionString(connectionString); auto shareUri = std::move(parsedConnectionString.FileServiceUri); - shareUri.AppendPath(shareName); + shareUri.AppendPath(Storage::Details::UrlEncodePath(shareName)); if (parsedConnectionString.KeyCredential) { @@ -115,14 +115,14 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { DirectoryClient ShareClient::GetDirectoryClient(const std::string& directoryPath) const { auto builder = m_shareUri; - builder.AppendPath(directoryPath); + builder.AppendPath(Storage::Details::UrlEncodePath(directoryPath)); return DirectoryClient(builder, m_pipeline); } FileClient ShareClient::GetFileClient(const std::string& filePath) const { auto builder = m_shareUri; - builder.AppendPath(filePath); + builder.AppendPath(Storage::Details::UrlEncodePath(filePath)); return FileClient(builder, m_pipeline); } diff --git a/sdk/storage/azure-storage-files-shares/src/share_directory_client.cpp b/sdk/storage/azure-storage-files-shares/src/share_directory_client.cpp index c93bc1e1f..5c8453095 100644 --- a/sdk/storage/azure-storage-files-shares/src/share_directory_client.cpp +++ b/sdk/storage/azure-storage-files-shares/src/share_directory_client.cpp @@ -24,8 +24,8 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { { auto parsedConnectionString = Azure::Storage::Details::ParseConnectionString(connectionString); auto directoryUri = std::move(parsedConnectionString.FileServiceUri); - directoryUri.AppendPath(shareName); - directoryUri.AppendPath(directoryPath); + directoryUri.AppendPath(Storage::Details::UrlEncodePath(shareName)); + directoryUri.AppendPath(Storage::Details::UrlEncodePath(directoryPath)); if (parsedConnectionString.KeyCredential) { @@ -118,14 +118,14 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { DirectoryClient DirectoryClient::GetSubDirectoryClient(const std::string& subDirectoryName) const { auto builder = m_shareDirectoryUri; - builder.AppendPath(subDirectoryName); + builder.AppendPath(Storage::Details::UrlEncodePath(subDirectoryName)); return DirectoryClient(builder, m_pipeline); } FileClient DirectoryClient::GetFileClient(const std::string& filePath) const { auto builder = m_shareDirectoryUri; - builder.AppendPath(filePath); + builder.AppendPath(Storage::Details::UrlEncodePath(filePath)); return FileClient(builder, m_pipeline); } diff --git a/sdk/storage/azure-storage-files-shares/src/share_file_client.cpp b/sdk/storage/azure-storage-files-shares/src/share_file_client.cpp index 48a305b90..b45832c68 100644 --- a/sdk/storage/azure-storage-files-shares/src/share_file_client.cpp +++ b/sdk/storage/azure-storage-files-shares/src/share_file_client.cpp @@ -27,8 +27,8 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { { auto parsedConnectionString = Azure::Storage::Details::ParseConnectionString(connectionString); auto fileUri = std::move(parsedConnectionString.FileServiceUri); - fileUri.AppendPath(shareName); - fileUri.AppendPath(filePath); + fileUri.AppendPath(Storage::Details::UrlEncodePath(shareName)); + fileUri.AppendPath(Storage::Details::UrlEncodePath(filePath)); if (parsedConnectionString.KeyCredential) { diff --git a/sdk/storage/azure-storage-files-shares/src/share_service_client.cpp b/sdk/storage/azure-storage-files-shares/src/share_service_client.cpp index 6e4c6f1b4..ab0a77882 100644 --- a/sdk/storage/azure-storage-files-shares/src/share_service_client.cpp +++ b/sdk/storage/azure-storage-files-shares/src/share_service_client.cpp @@ -111,7 +111,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { ShareClient ServiceClient::GetShareClient(const std::string& shareName) const { auto builder = m_serviceUri; - builder.AppendPath(shareName); + builder.AppendPath(Storage::Details::UrlEncodePath(shareName)); return ShareClient(builder, m_pipeline); } diff --git a/sdk/storage/azure-storage-files-shares/test/share_client_test.cpp b/sdk/storage/azure-storage-files-shares/test/share_client_test.cpp index c74ea1433..5a3fe0685 100644 --- a/sdk/storage/azure-storage-files-shares/test/share_client_test.cpp +++ b/sdk/storage/azure-storage-files-shares/test/share_client_test.cpp @@ -1,6 +1,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // SPDX-License-Identifier: MIT +#include "azure/storage/common/crypt.hpp" #include "share_client_test.hpp" #include @@ -298,4 +299,27 @@ namespace Azure { namespace Storage { namespace Test { EXPECT_THROW(m_shareClient->Delete(), StorageError); } + TEST_F(FileShareClientTest, UnencodedDirectoryFileNameWorks) + { + const std::string non_ascii_word = "\xE6\xB5\x8B\xE8\xAF\x95"; + const std::string encoded_non_ascii_word = "%E6%B5%8B%E8%AF%95"; + std::string baseName = "a b c !@#$%^&(,.;'[]{}`~) def" + non_ascii_word; + + { + std::string directoryName = baseName + RandomString(); + auto directoryClient = m_shareClient->GetDirectoryClient(directoryName); + EXPECT_NO_THROW(directoryClient.Create()); + auto directoryUrl = directoryClient.GetUri(); + EXPECT_EQ( + directoryUrl, + m_shareClient->GetUri() + "/" + Storage::Details::UrlEncodePath(directoryName)); + } + { + std::string fileName = baseName + RandomString(); + auto fileClient = m_shareClient->GetFileClient(fileName); + EXPECT_NO_THROW(fileClient.Create(1024)); + auto fileUrl = fileClient.GetUri(); + EXPECT_EQ(fileUrl, m_shareClient->GetUri() + "/" + Storage::Details::UrlEncodePath(fileName)); + } + } }}} // namespace Azure::Storage::Test diff --git a/sdk/storage/azure-storage-files-shares/version.txt b/sdk/storage/azure-storage-files-shares/version.txt index ffddd24fa..4740ad788 100644 --- a/sdk/storage/azure-storage-files-shares/version.txt +++ b/sdk/storage/azure-storage-files-shares/version.txt @@ -1 +1 @@ -1.0.0-beta.3 \ No newline at end of file +1.0.0-beta.4 \ No newline at end of file