Skip to content

Commit 9ffe097

Browse files
authored
Experiment: Allow bucket names ending with -s3alias / starting with xn-- (#51)
1 parent 8671f8a commit 9ffe097

File tree

3 files changed

+6
-11
lines changed

3 files changed

+6
-11
lines changed

Project.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "CloudStore"
22
uuid = "3365d9ee-d53b-4a56-812d-5344d5b716d7"
33
authors = ["quinnj <[email protected]>"]
4-
version = "1.6.3"
4+
version = "1.6.4"
55

66
[deps]
77
Base64 = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"

src/parse.jl

-2
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,6 @@ const AWS_REGIONS = Set{String}([
3939
function validate_bucket_name(bucket_name, accelerate)
4040
!(3 <= ncodeunits(bucket_name) <= 63) && throw(ArgumentError("Validation failed for `bucket` name $(repr(bucket_name)): Bucket names must be between 3 (min) and 63 (max) characters long."))
4141
occursin("..", bucket_name) && throw(ArgumentError("Validation failed for `bucket` name $(repr(bucket_name)): Bucket names must not contain two adjacent periods."))
42-
startswith(bucket_name, "xn--") && throw(ArgumentError("Validation failed for `bucket` name $(repr(bucket_name)): Bucket names must not start with the prefix `xn--`."))
43-
endswith(bucket_name, "-s3alias") && throw(ArgumentError("Validation failed for `bucket` name $(repr(bucket_name)): Bucket names must not end with the suffix `-s3alias`."))
4442
accelerate && occursin(".", bucket_name) && throw(ArgumentError("Validation failed for `bucket` name $(repr(bucket_name)): Buckets used with Amazon S3 Transfer Acceleration can't have dots (.) in their names."))
4543
!contains(bucket_name, r"^[a-z0-9][\.\-a-z0-9]+[a-z0-9]$") &&
4644
throw(ArgumentError("Validation failed for `bucket` name $(repr(bucket_name)): Bucket names can consist only of lowercase letters, numbers, dots (.), and hyphens (-). Bucket names must begin and end with a letter or number."))

test/runtests.jl

+5-8
Original file line numberDiff line numberDiff line change
@@ -882,10 +882,6 @@ end
882882
@test_throws ArgumentError parse_s3_url(bucket="a"^64, accelerate=false)
883883
@test_throws ArgumentError CloudStore.validate_bucket_name("a..b", false)
884884
@test !parse_s3_url(bucket="a..b", accelerate=false)[1]
885-
@test_throws ArgumentError CloudStore.validate_bucket_name("xn--abc", false)
886-
@test_throws ArgumentError parse_s3_url(bucket="xn--abc", accelerate=false)
887-
@test_throws ArgumentError CloudStore.validate_bucket_name("abcs-s3alias", false)
888-
@test_throws ArgumentError parse_s3_url(bucket="abcs-s3alias", accelerate=false)
889885
@test_throws ArgumentError CloudStore.validate_bucket_name("abcA", false)
890886
@test_throws ArgumentError parse_s3_url(bucket="abcA", accelerate=false)
891887
@test_throws ArgumentError CloudStore.validate_bucket_name("abc-", false)
@@ -909,10 +905,6 @@ end
909905
@test_throws ArgumentError parse_s3_url(bucket="a"^64, accelerate=true)
910906
@test_throws ArgumentError CloudStore.validate_bucket_name("a..b", true)
911907
@test !parse_s3_url(bucket="a..b", accelerate=true)[1]
912-
@test_throws ArgumentError CloudStore.validate_bucket_name("xn--abc", true)
913-
@test_throws ArgumentError parse_s3_url(bucket="xn--abc", accelerate=true)
914-
@test_throws ArgumentError CloudStore.validate_bucket_name("abcs-s3alias", true)
915-
@test_throws ArgumentError parse_s3_url(bucket="abcs-s3alias", accelerate=true)
916908
@test_throws ArgumentError CloudStore.validate_bucket_name("abcA", true)
917909
@test_throws ArgumentError parse_s3_url(bucket="abcA", accelerate=true)
918910
@test_throws ArgumentError CloudStore.validate_bucket_name("abc-", true)
@@ -927,6 +919,11 @@ end
927919
@test CloudStore.validate_bucket_name("a.b-c1", false) == "a.b-c1"
928920
@test CloudStore.validate_bucket_name("a"^63, false) == "a"^63
929921
@test CloudStore.validate_bucket_name("a"^3, false) == "a"^3
922+
# xn-- prefix and -s3alias suffix are apparently illegal in bucket names create by
923+
# the user but can be received from AWS, see e.g.
924+
# https://docs.aws.amazon.com/AmazonS3/latest/userguide/access-points-alias.html
925+
@test CloudStore.validate_bucket_name("xn--a", false) == "xn--a"
926+
@test CloudStore.validate_bucket_name("a-s3alias", false) == "a-s3alias"
930927

931928
@test_throws ArgumentError("Validation failed for `region` \"xx-xxxx-x\"") CloudStore.parseAWSBucketRegionKey("https://bucket.vpce-1a2b3c4d-5e6f.s3.xx-xxxx-x.vpce.amazonaws.com/bucket-name")
932929
@test_throws ArgumentError("Validation failed for `bucket` name \"bn\": Bucket names must be between 3 (min) and 63 (max) characters long.") CloudStore.parseAWSBucketRegionKey("https://bucket.vpce-1a2b3c4d-5e6f.s3.us-west-2.vpce.amazonaws.com/bn")

0 commit comments

Comments
 (0)