diff --git a/S3/BaseUtils.py b/S3/BaseUtils.py index 69590649..035be720 100644 --- a/S3/BaseUtils.py +++ b/S3/BaseUtils.py @@ -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 diff --git a/S3/Utils.py b/S3/Utils.py index cf6e7482..88313b33 100644 --- a/S3/Utils.py +++ b/S3/Utils.py @@ -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])) @@ -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") diff --git a/run-tests.py b/run-tests.py index 7ce84a11..a9f3f865 100755 --- a/run-tests.py +++ b/run-tests.py @@ -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 @@ -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']) @@ -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']) @@ -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'])