Skip to content

Commit dca86e5

Browse files
Validate underscores in host names successfully
For eg, `minio_server` should be treated as valid hostname. Fixes #760
1 parent 3efe9e9 commit dca86e5

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

minio/helpers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353

5454
_VALID_BUCKETNAME_REGEX = re.compile('^[a-z0-9][a-z0-9\\.\\-]+[a-z0-9]$')
5555
_ALLOWED_HOSTNAME_REGEX = re.compile(
56-
'^((?!-)[A-Z\\d-]{1,63}(?<!-)\\.)*((?!-)[A-Z\\d-]{1,63}(?<!-))$',
56+
'^((?!-)(?!_)[A-Z\_\\d-]{1,63}(?<!-)(?<!_)\\.)*((?!_)(?!-)[A-Z\_\\d-]{1,63}(?<!-)(?<!_))$',
5757
re.IGNORECASE)
5858

5959
_EXTRACT_REGION_REGEX = re.compile('s3[.-]?(.+?).amazonaws.com')

tests/unit/get_s3_endpoint_test.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,6 @@ def test_get_s3_endpoint(self):
2727
def test_is_valid_endpoint(self):
2828
eq_(True, is_valid_endpoint('s3.amazonaws.com'))
2929
eq_(True, is_valid_endpoint('s3.cn-north-1.amazonaws.com.cn'))
30+
eq_(True, is_valid_endpoint('minio_server:9000'))
31+
eq_(True, is_valid_endpoint('s3.server_1.amazonaws.com'))
32+

0 commit comments

Comments
 (0)