From 6750e8da440da0cecbb924a3989142da448fb84d Mon Sep 17 00:00:00 2001 From: Konstantin Ryabitsev Date: Thu, 1 Sep 2022 17:20:37 -0400 Subject: mbox: accept arbitrary public-inbox URLs When "b4 am" or "b4 mbox" is passed an arbitrary URL that matches a public-inbox scheme but that doesn't match the midmask URL, assume the user knows what they are doing and attempt to retrieve the mbox. Suggested-by: Philippe Blain Link: https://msgid.link/f2b0f3c1-d98d-979d-1513-18f2491f4267@gmail.com Signed-off-by: Konstantin Ryabitsev --- b4/__init__.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/b4/__init__.py b/b4/__init__.py index 5b0bb6e..995bd7e 100644 --- a/b4/__init__.py +++ b/b4/__init__.py @@ -2367,10 +2367,16 @@ def get_msgid(cmdargs: argparse.Namespace) -> Optional[str]: msgid = urllib.parse.unquote(chunks[0]) return msgid - # Is it a lore URL? + # Does it look like a public-inbox URL? matches = re.search(r'^https?://[^/]+/([^/]+)/([^/]+@[^/]+)', msgid, re.IGNORECASE) if matches: chunks = matches.groups() + config = get_main_config() + myloc = urllib.parse.urlparse(config['midmask']) + wantloc = urllib.parse.urlparse(msgid) + if myloc.netloc != wantloc.netloc: + logger.debug('Overriding midmask with passed url parameters') + config['midmask'] = f'{wantloc.scheme}://{wantloc.netloc}/{chunks[0]}/%s' msgid = urllib.parse.unquote(chunks[1]) # Infer the project name from the URL, if possible if chunks[0] != 'r': -- cgit v1.2.3