Skip to content

Commit

Permalink
Validate underscores in host names successfully
Browse files Browse the repository at this point in the history
For eg, `minio_server` should be treated as valid hostname.

Fixes minio#760
  • Loading branch information
Praveenrajmani committed May 15, 2019
1 parent 3efe9e9 commit 412836d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
3 changes: 2 additions & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ environment:

install:
# We need wheel installed to build wheels
- "%PYTHON%\\python.exe -m pip install wheel faker nose"
- "%PYTHON%\\python.exe -m pip install --upgrade pip"
- "%PYTHON%\\python.exe -m pip install wheel faker nose mock funcsigs"
- "%PYTHON%\\python.exe setup.py install"

build: off
Expand Down
2 changes: 1 addition & 1 deletion minio/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@

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

_EXTRACT_REGION_REGEX = re.compile('s3[.-]?(.+?).amazonaws.com')
Expand Down
3 changes: 3 additions & 0 deletions tests/unit/get_s3_endpoint_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,6 @@ def test_get_s3_endpoint(self):
def test_is_valid_endpoint(self):
eq_(True, is_valid_endpoint('s3.amazonaws.com'))
eq_(True, is_valid_endpoint('s3.cn-north-1.amazonaws.com.cn'))
eq_(True, is_valid_endpoint('minio_server:9000'))
eq_(True, is_valid_endpoint('s3.server_1.amazonaws.com'))

0 comments on commit 412836d

Please sign in to comment.