From 4f1e6dbbc83739332653c0376dfb772d90312211 Mon Sep 17 00:00:00 2001 From: oxeo0 Date: Fri, 30 May 2025 02:31:35 +0200 Subject: [PATCH] small fixes (no protocol requirement for isonion, bool return types) --- scripts/lantern.py | 5 +++-- scripts/utils.py | 9 +++++---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/scripts/lantern.py b/scripts/lantern.py index 59fce7a..eb22e3f 100644 --- a/scripts/lantern.py +++ b/scripts/lantern.py @@ -244,7 +244,7 @@ Maintenance: uvdf = uvdf.sort_values(by=["Category","Score"], ascending=[True,False]) # sorting categories print_colors("[+] New row added! now writing the csv file") else: - print("Adding new row in verified.csv since descriptioln is not empty") + print("Adding new row in verified.csv since description is not empty") vdf.loc[-1] = newrow # adding a row vdf = vdf.sort_values(by=["Category","Score"], ascending=[True,False]) # sorting categories print_colors("[+] New row added! now writing the csv file") @@ -652,8 +652,9 @@ Maintenance: csvdf.at[i, 'Sensitive'] = "NO" csvdf.to_csv(csvfilepath, index=False) + print('sync:::', csvdf.at[i, 'Instance']) ### SANITY CHECK 1: Mark all the rows that have incorrect formatting for deletion### - if IsURLValid(csvdf.at[i, 'Instance']) is False or IsCategoryValid(csvdf.at[i, 'Category']) is False or IsNameValid(csvdf.at[i, 'Name']) is False or IsURLValid(csvdf.at[i, 'URL']) is False or IsStatusValid(csvdf.at[i, 'Sensitive']) is False or IsDescriptionValid(csvdf.at[i, 'Description']) is False or IsStatusValid(csvdf.at[i, 'Status']) is False or IsScoreValid(csvdf.at[i, 'Score']) is False: + if IsURLValid(str(csvdf.at[i, 'Instance'])) is False or IsCategoryValid(csvdf.at[i, 'Category']) is False or IsNameValid(csvdf.at[i, 'Name']) is False or IsURLValid(csvdf.at[i, 'URL']) is False or IsStatusValid(csvdf.at[i, 'Sensitive']) is False or IsDescriptionValid(csvdf.at[i, 'Description']) is False or IsStatusValid(csvdf.at[i, 'Status']) is False or IsScoreValid(csvdf.at[i, 'Score']) is False: #mark the row for deletion as it has invalid inputs if i not in rows2delete: print_colors(f"Marking row {i} for deletion, as it has invalid inputs") diff --git a/scripts/utils.py b/scripts/utils.py index 42e8e43..590059e 100644 --- a/scripts/utils.py +++ b/scripts/utils.py @@ -25,8 +25,9 @@ CLEARNET_URL_PATTERN = re.compile( ) # pattern for onion urls (56 bytes of base32 alphabet + .onion) +# it works also without http(s)://, so just the hostname will also go through ONION_URL_PATTERN = re.compile( - r"^https?:\/\/([a-zA-Z0-9-]+\.)*[a-z2-7-]{56}\.onion[^\s]*$" + r"^(https?:\/\/)?([a-zA-Z0-9-]+\.)*[a-z2-7-]{56}\.onion[^\s]*$" ) # pattern for simplex chatroom links @@ -49,7 +50,7 @@ def IsSimplexChatroomValid(url: str) -> bool: Returns True if URL is a SimpleX chatroom, False otherwise """ - return SIMPLEX_CHATROOM_PATTERN.match(url) + return bool(SIMPLEX_CHATROOM_PATTERN.match(url)) def RecognizeSimplexType(url: str) -> str: """ @@ -82,14 +83,14 @@ def IsClearnetLinkValid(url: str) -> bool: Returns True if URL is a valid clearnet URL False otherwise """ - return CLEARNET_URL_PATTERN.match(url) + return bool(CLEARNET_URL_PATTERN.match(url)) def IsOnionLinkValid(url: str) -> bool: """ Returns True if URL is a valid onion URL False otherwise """ - return ONION_URL_PATTERN.match(url) + return bool(ONION_URL_PATTERN.match(url)) def RecognizeURLType(url: str) -> str: """