From 8e54bba4a735cb2398e6441766c79e7a101ee93d Mon Sep 17 00:00:00 2001 From: Chris Caron Date: Sun, 8 Oct 2023 16:44:46 -0400 Subject: [PATCH] updated handling of parse_url secure flag check --- apprise/URLBase.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/apprise/URLBase.py b/apprise/URLBase.py index b69ba9fc4f..15dd292424 100644 --- a/apprise/URLBase.py +++ b/apprise/URLBase.py @@ -204,7 +204,14 @@ def __init__(self, asset=None, **kwargs): self.verify_certificate = parse_bool(kwargs.get('verify', True)) # Secure Mode - self.secure = kwargs.get('secure', False) + self.secure = kwargs.get('secure', None) + try: + if not isinstance(self.secure, bool): + # Attempt to detect + self.secure = kwargs.get('schema', '')[-1].lower() == 's' + + except (TypeError, IndexError): + self.secure = False self.host = URLBase.unquote(kwargs.get('host')) self.port = kwargs.get('port') @@ -664,7 +671,8 @@ def url_parameters(self, *args, **kwargs): } @staticmethod - def parse_url(url, verify_host=True, plus_to_space=False): + def parse_url(url, verify_host=True, plus_to_space=False, + strict_port=False): """Parses the URL and returns it broken apart into a dictionary. This is very specific and customized for Apprise. @@ -685,13 +693,13 @@ def parse_url(url, verify_host=True, plus_to_space=False): results = parse_url( url, default_schema='unknown', verify_host=verify_host, - plus_to_space=plus_to_space) + plus_to_space=plus_to_space, strict_port=strict_port) if not results: # We're done; we failed to parse our url return results - # if our URL ends with an 's', then assueme our secure flag is set. + # if our URL ends with an 's', then assume our secure flag is set. results['secure'] = (results['schema'][-1] == 's') # Support SSL Certificate 'verify' keyword. Default to being enabled