From: Philipp Spitzer Date: Tue, 8 Apr 2014 18:00:20 +0000 (+0200) Subject: Fixed bug: Some exceptions were not caught. X-Git-Tag: 0.0.2~10 X-Git-Url: https://git.toastfreeware.priv.at/toast/tdyndns.git/commitdiff_plain/a14d6ca7f65dfd40737dd5701c479c2b6cc1b75e Fixed bug: Some exceptions were not caught. --- diff --git a/cgi-bin/dyndns.py b/cgi-bin/dyndns.py index d62ebfc..1d3e2d2 100755 --- a/cgi-bin/dyndns.py +++ b/cgi-bin/dyndns.py @@ -89,24 +89,23 @@ system = fields.getvalue('system') url = fields.getvalue('url') -# Optional Auth Basic -auth = os.environ.get('HTTP_AUTHORIZATION') # auth == 'Basic cGhpbGlwcDpka2ZhamRrZg==' -if auth: # empty string if HTTP_AUTHORIZATION not present - auth_parts = auth.split(' ') - auth_method = 'Basic' - if len(auth_parts) != 2 or auth_parts[0] != auth_method: - raise AuthWrongMethod() - try: - auth_decoded = base64.b64decode(auth_parts[1]) # auth_decoded == 'philipp:dkfajdkf' - except TypeError: - raise AuthBasicError() - auth_decoded_parts = auth_decoded.split(':') - if len(auth_decoded_parts) != 2: - raise AuthBasicError() - username, password = auth_decoded_parts - - try: + # Optional Auth Basic + auth = os.environ.get('HTTP_AUTHORIZATION') # auth == 'Basic cGhpbGlwcDpka2ZhamRrZg==' + if auth: # empty string if HTTP_AUTHORIZATION not present + auth_parts = auth.split(' ') + auth_method = 'Basic' + if len(auth_parts) != 2 or auth_parts[0] != auth_method: + raise AuthWrongMethod() + try: + auth_decoded = base64.b64decode(auth_parts[1]) # auth_decoded == 'philipp:dkfajdkf' + except TypeError: + raise AuthBasicError() + auth_decoded_parts = auth_decoded.split(':') + if len(auth_decoded_parts) != 2: + raise AuthBasicError() + username, password = auth_decoded_parts + # check username and password if username is None and password is None: raise CredentialsMissing()