Skip to content

Commit

Permalink
updated handling of parse_url secure flag check
Browse files Browse the repository at this point in the history
  • Loading branch information
caronc committed Oct 8, 2023
1 parent 480d0e0 commit 8e54bba
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions apprise/URLBase.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down Expand Up @@ -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.
Expand All @@ -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
Expand Down

0 comments on commit 8e54bba

Please sign in to comment.