Make detection of pasted URLs a little stricter

This commit is contained in:
Kovid Goyal 2022-03-24 17:30:47 +05:30
parent 3c67e991c2
commit e151b8e604
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -1263,7 +1263,10 @@ class Window:
return
if 'quote-urls-at-prompt' in opts.paste_actions and self.at_prompt:
prefixes = '|'.join(opts.url_prefixes)
if re.match(f'{prefixes}:', text) is not None:
m = re.match(f'({prefixes}):(.+)', text)
if m is not None:
scheme, rest = m.group(1), m.group(2)
if rest.startswith('//') or scheme in ('mailto', 'irc'):
import shlex
text = shlex.quote(text)
btext = text.encode('utf-8')