diff options
author | Konstantin Ryabitsev <konstantin@linuxfoundation.org> | 2022-09-01 17:20:37 -0400 |
---|---|---|
committer | Konstantin Ryabitsev <konstantin@linuxfoundation.org> | 2022-09-01 17:20:37 -0400 |
commit | 6750e8da440da0cecbb924a3989142da448fb84d (patch) | |
tree | 717e25ce73224e5aa9c7db48393849a72b0aa8f8 | |
parent | ce8a43b22eb68c03d57bcd810b2c3bde1431634c (diff) | |
download | b4-6750e8da440da0cecbb924a3989142da448fb84d.tar.gz |
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 <levraiphilippeblain@gmail.com>
Link: https://msgid.link/f2b0f3c1-d98d-979d-1513-18f2491f4267@gmail.com
Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
-rw-r--r-- | b4/__init__.py | 8 |
1 files changed, 7 insertions, 1 deletions
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': |