Files
maigret/tests
jichaowang02-langandGitHub f8c35b09e3 Fix URLMatcher eating leading host chars (unescaped dots in prefix regex) (#2808)
URLMatcher._HTTP_URL_RE_STR was "^https?://(www.|m.)?(.+)$". The dots in
the optional (www.|m.)? subdomain-prefix group were unescaped, so each `.`
matched ANY character. For a host that simply starts with `m` or `www`
(not the literal `m.`/`www.` prefix), the group greedily ate the first
characters:

    extract_main_part('https://medium.com/alice')  -> 'dium.com/alice'
    extract_main_part('https://myspace.com/bob')   -> 'space.com/bob'

extract_main_part feeds make_profile_url_regexp / get_url_template, so the
generated site-detection regexp was corrupted too (medium.com -> dium.com),
and the loose prefix could match bogus hosts like `xmedium.com`. 170+ hosts
in resources/data.json start with `m`.

Fix: escape the dots with a raw string, r"^https?://(www\.|m\.)?(.+)$".
Genuine `m.`/`www.` prefixes are still stripped
(m.wikipedia.org -> wikipedia.org). The two existing tests that pinned the
unescaped pattern string are updated to the corrected form, and a
regression test covers hosts beginning with m/www.
2026-06-29 14:59:31 +02:00
..
2021-01-02 00:23:58 +03:00
2021-05-18 00:43:56 +03:00
2026-06-17 15:15:32 +02:00