Merge pull request #18059 from excitoon/patch-2

Fixed `std::out_of_range: basic_string` in S3 URL parsing
This commit is contained in:
alexey-milovidov 2020-12-14 22:56:39 +03:00 committed by GitHub
commit 7184746f45
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -368,8 +368,12 @@ namespace S3
throw Exception(
"Bucket name length is out of bounds in virtual hosted style S3 URI: " + bucket + " (" + uri.toString() + ")", ErrorCodes::BAD_ARGUMENTS);
/// Remove leading '/' from path to extract key.
key = uri.getPath().substr(1);
if (!uri.getPath().empty())
{
/// Remove leading '/' from path to extract key.
key = uri.getPath().substr(1);
}
if (key.empty() || key == "/")
throw Exception("Key name is empty in virtual hosted style S3 URI: " + key + " (" + uri.toString() + ")", ErrorCodes::BAD_ARGUMENTS);
boost::to_upper(name);