Skip to content

Commit

Permalink
harden version check
Browse files Browse the repository at this point in the history
  • Loading branch information
HenriWahl committed Oct 10, 2023
1 parent 4537339 commit 1f0f397
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
6 changes: 5 additions & 1 deletion Nagstamon/QUI/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7010,7 +7010,11 @@ def check(self):
giveback='raw',
no_auth=True)
# stop searching the available download URLs
if response.error == "" and not response.result.startswith('<'):
if response.error == "" and \
not response.result.startswith('<') and \
not '\n' in response.result and \
len(response.result) > 5 and \
response.result[0].isdigit():
latest_version = response.result.strip()
break
# ignore TLS error in case it was caused by requesting latest version - not important for monitoring
Expand Down
9 changes: 6 additions & 3 deletions Nagstamon/Servers/Multisite.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,18 +179,21 @@ def _get_url(self, url):
# return ''

# looks like cookieauth
elif content.startswith('<'):
elif content.startswith('<') or\
'<!DOCTYPE html>' in content:
self.CookieAuth = True
# if first attempt login and then try to get data again
if not self._is_auth_in_cookies():
self._get_cookie_login()
result = self.FetchURL(url, 'raw')
content, error = result.result, result.error
if content.startswith('<'):
if content.startswith('<') or\
'<!DOCTYPE html>' in content:
return ''

# if finally still some <HTML> is sent this looks like a new login due to password change
if content.startswith('<'):
if content.startswith('<') or\
'<!DOCTYPE html>' in content:
self.refresh_authentication = True
return ''

Expand Down

0 comments on commit 1f0f397

Please sign in to comment.