diff --git a/s3-bucket-list b/s3-bucket-list index 352e65e..6d20670 100755 --- a/s3-bucket-list +++ b/s3-bucket-list @@ -3,12 +3,16 @@ import html import http.client import json import os +import re import shlex import ssl import sys import urllib.parse +RESPONSE_PATTERN = re.compile(r'''^<\?xml version=(["'])1\.0\1 encoding=(["'])UTF-8\2\?>''' '\n?' r''''''.encode('ascii')) + + # Arguments i = 1 withListUrls = False @@ -79,7 +83,7 @@ while True: break attempt += 1 continue - if not body.startswith(b'\n') and not body.startswith(b""): + if not RESPONSE_PATTERN.match(body): raise RuntimeError(f'Invalid body: {body[:200]}...') if b'' in body[:200] and 'marker' in params: