diff --git a/linkcheck/checker/mailtourl.py b/linkcheck/checker/mailtourl.py index 9d36f32d..e3450cce 100644 --- a/linkcheck/checker/mailtourl.py +++ b/linkcheck/checker/mailtourl.py @@ -159,7 +159,7 @@ class MailtoUrl (urlbase.UrlBase): {"addr": mail}, valid=False, overwrite=False) return # note: be sure to use rsplit since "@" can occur in local part - local, domain = mail.rsplit("@", 1) + local, domain = urlutil.decode_for_unquote(mail).rsplit("@", 1) if not local: self.set_result(_("Missing local part of mail address `%(addr)s'.") % \ {"addr": mail}, valid=False, overwrite=False) @@ -248,7 +248,7 @@ class MailtoUrl (urlbase.UrlBase): from dns.exception import DNSException log.debug(LOG_CHECK, "checking mail address %r", mail) mail = strformat.ascii_safe(mail) - username, domain = mail.rsplit('@', 1) + username, domain = urlutil.decode_for_unquote(mail).rsplit('@', 1) log.debug(LOG_CHECK, "looking up MX mailhost %r", domain) try: answers = resolver.query(domain, 'MX') diff --git a/linkcheck/url.py b/linkcheck/url.py index 2322cd76..ff40646c 100644 --- a/linkcheck/url.py +++ b/linkcheck/url.py @@ -256,8 +256,9 @@ def url_fix_common_typos (url): def url_fix_mailto_urlsplit (urlparts): """Split query part of mailto url if found.""" - if "?" in urlparts[2]: - urlparts[2], urlparts[3] = urlparts[2].split('?', 1) + sep = b"?" if isinstance(urlparts[2], bytes) else u"?" + if sep in urlparts[2]: + urlparts[2], urlparts[3] = urlparts[2].split(sep, 1) # wayback urls include in the path http[s]://. By default the # tidying mechanism in linkchecker encodes the : and deletes the second slash