Skip to content

Commit

Permalink
cleanup: fixes "invalid escape sequence" Syntax Warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
fviard committed Oct 19, 2023
1 parent 9ecb2d8 commit 7ebafbe
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions S3/BaseUtils.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@



RE_S3_DATESTRING = re.compile('\.[0-9]*(?:[Z\\-\\+]*?)')
RE_XML_NAMESPACE = re.compile(b'^(<?[^>]+?>\s*|\s*)(<\w+) xmlns=[\'"](https?://[^\'"]+)[\'"]', re.MULTILINE)
RE_S3_DATESTRING = re.compile('\\.[0-9]*(?:[Z\\-\\+]*?)')
RE_XML_NAMESPACE = re.compile(b'^(<?[^>]+?>\\s*|\\s*)(<\\w+) xmlns=[\'"](https?://[^\'"]+)[\'"]', re.MULTILINE)


# Date and time helpers
Expand Down
12 changes: 6 additions & 6 deletions S3/Utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,11 +223,11 @@ def time_to_epoch(t):

def check_bucket_name(bucket, dns_strict=True):
if dns_strict:
invalid = re.search("([^a-z0-9\.-])", bucket, re.UNICODE)
invalid = re.search(r"([^a-z0-9\.-])", bucket, re.UNICODE)
if invalid:
raise S3.Exceptions.ParameterError("Bucket name '%s' contains disallowed character '%s'. The only supported ones are: lowercase us-ascii letters (a-z), digits (0-9), dot (.) and hyphen (-)." % (bucket, invalid.groups()[0]))
else:
invalid = re.search("([^A-Za-z0-9\._-])", bucket, re.UNICODE)
invalid = re.search(r"([^A-Za-z0-9\._-])", bucket, re.UNICODE)
if invalid:
raise S3.Exceptions.ParameterError("Bucket name '%s' contains disallowed character '%s'. The only supported ones are: us-ascii letters (a-z, A-Z), digits (0-9), dot (.), hyphen (-) and underscore (_)." % (bucket, invalid.groups()[0]))

Expand All @@ -238,13 +238,13 @@ def check_bucket_name(bucket, dns_strict=True):
if dns_strict:
if len(bucket) > 63:
raise S3.Exceptions.ParameterError("Bucket name '%s' is too long (max 63 characters)" % bucket)
if re.search("-\.", bucket, re.UNICODE):
if re.search(r"-\.", bucket, re.UNICODE):
raise S3.Exceptions.ParameterError("Bucket name '%s' must not contain sequence '-.' for DNS compatibility" % bucket)
if re.search("\.\.", bucket, re.UNICODE):
if re.search(r"\.\.", bucket, re.UNICODE):
raise S3.Exceptions.ParameterError("Bucket name '%s' must not contain sequence '..' for DNS compatibility" % bucket)
if not re.search("^[0-9a-z]", bucket, re.UNICODE):
if not re.search(r"^[0-9a-z]", bucket, re.UNICODE):
raise S3.Exceptions.ParameterError("Bucket name '%s' must start with a letter or a digit" % bucket)
if not re.search("[0-9a-z]$", bucket, re.UNICODE):
if not re.search(r"[0-9a-z]$", bucket, re.UNICODE):
raise S3.Exceptions.ParameterError("Bucket name '%s' must end with a letter or a digit" % bucket)
return True
__all__.append("check_bucket_name")
Expand Down
8 changes: 4 additions & 4 deletions run-tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ def pbucket(tail):
must_find = ["ERROR: Upload of 'testsuite/permission-tests/permission-denied.txt' is not possible (Reason: Permission denied)",
"WARNING: 32 non-printable characters replaced in: crappy-file-name/non-printables",
],
must_not_find_re = ["demo/", "^(?!WARNING: Skipping).*\.png$", "permission-denied-dir"],
must_not_find_re = ["demo/", r"^(?!WARNING: Skipping).*\.png$", "permission-denied-dir"],
retcode = EX_PARTIAL)

## ====== Create new file and sync with caching enabled
Expand Down Expand Up @@ -702,7 +702,7 @@ def pbucket(tail):
## ====== Verify ACL and MIME type
test_s3cmd("Verify ACL and MIME type", ['info', '%s/copy/etc2/Logo.PNG' % pbucket(2) ],
must_find_re = [ "MIME type:.*image/png",
"ACL:.*\*anon\*: READ",
r"ACL:.*\*anon\*: READ",
"URL:.*https?://%s.%s/copy/etc2/Logo.PNG" % (bucket(2), cfg.host_base) ],
skip_if_profile = ['minio'])

Expand All @@ -716,7 +716,7 @@ def pbucket(tail):

test_s3cmd("Verify ACL and MIME type", ['info', '%s/copy/etc2/Logo.PNG' % pbucket(2) ],
must_find_re = [ "MIME type:.*binary/octet-stream",
"ACL:.*\*anon\*: READ",
r"ACL:.*\*anon\*: READ",
"URL:.*https?://%s.%s/copy/etc2/Logo.PNG" % (bucket(2), cfg.host_base) ],
skip_if_profile = ['minio'])

Expand All @@ -731,7 +731,7 @@ def pbucket(tail):

test_s3cmd("Verify ACL and MIME type", ['info', '%s/copy/etc2/Logo.PNG' % pbucket(2) ],
must_find_re = [ "MIME type:.*image/png",
"ACL:.*\*anon\*: READ",
r"ACL:.*\*anon\*: READ",
"URL:.*https?://%s.%s/copy/etc2/Logo.PNG" % (bucket(2), cfg.host_base) ],
skip_if_profile = ['minio'])

Expand Down

0 comments on commit 7ebafbe

Please sign in to comment.