From a2c964bfc24a82eca83c3a4e16dddea1185d63e7 Mon Sep 17 00:00:00 2001 From: Sushanth012 <146400678+Sushanth012@users.noreply.github.com> Date: Mon, 31 Aug 2026 01:31:38 -0700 Subject: [PATCH] Escape the dollar sign when building profile URL regexps (#3051) --- maigret/utils.py | 2 +- tests/test_sites.py | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/maigret/utils.py b/maigret/utils.py index 959ba58f..416ba4d8 100644 --- a/maigret/utils.py +++ b/maigret/utils.py @@ -50,7 +50,7 @@ def enrich_link_str(link: str) -> str: class URLMatcher: _HTTP_URL_RE_STR = r"^https?://(www\.|m\.)?(.+)$" HTTP_URL_RE = re.compile(_HTTP_URL_RE_STR) - UNSAFE_SYMBOLS = ".?" + UNSAFE_SYMBOLS = ".?$" @classmethod def extract_main_part(self, url: str) -> str: diff --git a/tests/test_sites.py b/tests/test_sites.py index 8b57e7e1..50126491 100644 --- a/tests/test_sites.py +++ b/tests/test_sites.py @@ -184,6 +184,21 @@ def test_extract_id_from_url_skips_none_groups(): ) +def test_extract_id_from_url_handles_literal_dollar_prefix(): + site = MaigretSite( + "Cash App", + { + "urlMain": "https://cash.app", + "url": "https://cash.app/${username}", + }, + ) + + assert site.extract_id_from_url("https://cash.app/$alice") == ( + "alice", + "username", + ) + + def test_ranked_sites_dict(): db = MaigretDatabase() db.update_site(MaigretSite('3', {'alexaRank': 1000, 'engine': 'ucoz'}))