From 74220b50dfe57c48e31de50993f29cdddf0fdc5b Mon Sep 17 00:00:00 2001 From: Lorenzo Paderi Date: Tue, 3 Sep 2024 11:21:08 +0200 Subject: [PATCH] fixed incorrect url detection for some links --- data/it.mijorus.gearlever.appdata.xml.in | 5 +++++ meson.build | 2 +- src/lib/utils.py | 10 ++++++---- src/models/UpdateManager.py | 3 +++ 4 files changed, 15 insertions(+), 5 deletions(-) diff --git a/data/it.mijorus.gearlever.appdata.xml.in b/data/it.mijorus.gearlever.appdata.xml.in index 47e107b..280fcbc 100644 --- a/data/it.mijorus.gearlever.appdata.xml.in +++ b/data/it.mijorus.gearlever.appdata.xml.in @@ -20,6 +20,11 @@

An utility to manage AppImages with ease! Gear lever will organize and manage AppImage files for you, generate desktop entries and app metadata, update apps in-place or keep multiple versions side-by-side.

+ + +

- Fixed incorrect url detection for some links

+
+

- Updated appimage type detection according to the specs

diff --git a/meson.build b/meson.build index dcf5393..bcfacb3 100644 --- a/meson.build +++ b/meson.build @@ -1,5 +1,5 @@ project('gearlever', - version: '2.0.6', + version: '2.0.7', meson_version: '>= 0.59.0', default_options: [ 'warning_level=2', ], diff --git a/src/lib/utils.py b/src/lib/utils.py index 8d9fbdf..55507f7 100644 --- a/src/lib/utils.py +++ b/src/lib/utils.py @@ -129,12 +129,14 @@ def get_element_without_overscroll(arr: list, index: int): def url_is_valid(url: str) -> bool: url_regex = re.compile( r'^(?:http|https)://' # http:// or https:// - r'[a-z0-9]+(?:-[a-z0-9]+)*' # domain name - r'(?:\.[a-z]{2,})+' # .com, .net, etc. - r'(?:/?|[/?]\S+)$' # /, /path, or /path?query=string , re.IGNORECASE) - return True if url_regex.match(url) else False + is_valid = True if url_regex.match(url) else False + + if not is_valid: + logging.warn(f'Provided url "{url}" is not a valid url') + + return is_valid def get_random_string(): return ''.join((random.choice('abcdxyzpqr123456789') for i in range(10))) diff --git a/src/models/UpdateManager.py b/src/models/UpdateManager.py index 955141b..5c233a5 100644 --- a/src/models/UpdateManager.py +++ b/src/models/UpdateManager.py @@ -123,6 +123,9 @@ def can_handle_link(url: str): logging.debug(f'{url} responded with content-type: {ct}') ct_supported = ct in [*AppImageProvider.supported_mimes, 'binary/octet-stream', 'application/octet-stream'] + if not ct_supported: + logging.warn(f'Provided url "{url}" does not return a valid content-type header') + return ct_supported def download(self, status_update_cb) -> str: