Skip to content

Commit

Permalink
fixed incorrect url detection for some links
Browse files Browse the repository at this point in the history
  • Loading branch information
mijorus committed Sep 3, 2024
1 parent 98d10c6 commit 74220b5
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 5 deletions.
5 changes: 5 additions & 0 deletions data/it.mijorus.gearlever.appdata.xml.in
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@
<p>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.</p>
</description>
<releases>
<release type="stable" version="2.0.7" date="2024-09-03:00:00Z">
<description>
<p>- Fixed incorrect url detection for some links</p>
</description>
</release>
<release type="stable" version="2.0.6" date="2024-08-08:00:00Z">
<description>
<p>- Updated appimage type detection according to the specs</p>
Expand Down
2 changes: 1 addition & 1 deletion meson.build
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
project('gearlever',
version: '2.0.6',
version: '2.0.7',
meson_version: '>= 0.59.0',
default_options: [ 'warning_level=2',
],
Expand Down
10 changes: 6 additions & 4 deletions src/lib/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)))
Expand Down
3 changes: 3 additions & 0 deletions src/models/UpdateManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 74220b5

Please sign in to comment.