fix even more parsing related stuff, including namespace conflicts

This commit is contained in:
cynthia 2025-04-15 00:34:42 +01:00
parent 013673fffb
commit ca4d949175

View file

@ -1,5 +1,5 @@
import re
from utils import IsUrlValid
from SimpleX.utils import IsUrlValid
import urllib.parse
#simplex:/contact#/?v=2-7&smp=smp%3A%2F%2FBD4qkVq8lJUgjHt0kUaxeQBYsKaxDejeecxm6-2vOwI%3D%40 b6geeakpwskovltbesvy3b6ah3ewxfmnhnshojndmpp7wcv2df7bnead.onion %2FOReK0M4-3C5NeZyQx_yFuTHSknVVS-3h%23%2F%3Fv%3D1-3%26dh%3DMCowBQYDK2VuAyEANi5VHx-Q1mIKmgZEg2ls47NGSlntttvcgLLbfKBpym4%253D&data=%7B%22groupLinkId%22%3A%22ndniy85i4DjITgVhB-MXnQ%3D%3D%22%7D
@ -19,8 +19,7 @@ hostname_pattern = re.compile(r'^(?:[a-zA-Z0-9.-]+|[0-9]{1,3}(?:\.[0-9]{1,3}){3}
def IsSimpleXChatroomValid(url: str) -> bool:
"""Validate the SimpleX chatroom URL."""
REQUIRED_SUBSTRING = "contact#/?v=2-7&smp=smp%3A%2F"
REQUIRED_SUBSTRING2 = "contact/#/?v=2-7&smp=smp%3A%2F"
REQUIRED_SUBSTRING = "#/?v=2-7&smp=smp%3A%2F"
# Step 1: Check if it starts with http://, https://, or simplex:/
if url.startswith(('http://', 'https://', 'simplex:/')):
@ -31,7 +30,7 @@ def IsSimpleXChatroomValid(url: str) -> bool:
return False # Must start with one of the valid protocols
# Step 2: Check for the presence of the required substring
if REQUIRED_SUBSTRING not in url and REQUIRED_SUBSTRING2 not in url:
if REQUIRED_SUBSTRING not in url:
return False # Required substring not found
# Step 3: Extract the part after "smp=smp%3A%2F"