Function: textsec-domain-suspicious-p
textsec-domain-suspicious-p is a byte-compiled function defined in
textsec.el.gz.
Signature
(textsec-domain-suspicious-p DOMAIN)
Documentation
Say whether DOMAIN's name looks suspicious.
Return nil if it isn't suspicious. If it is, return a string explaining the potential problem.
Domain names are considered suspicious if they use characters that can look similar to other characters when displayed, or use characters that are not allowed by Unicode's IDNA mapping, or use certain other unusual mixtures of characters.
Source Code
;; Defined in /usr/src/emacs/lisp/international/textsec.el.gz
(defun textsec-domain-suspicious-p (domain)
"Say whether DOMAIN's name looks suspicious.
Return nil if it isn't suspicious. If it is, return a string explaining
the potential problem.
Domain names are considered suspicious if they use characters
that can look similar to other characters when displayed, or
use characters that are not allowed by Unicode's IDNA mapping,
or use certain other unusual mixtures of characters."
(catch 'found
;; Plain domains aren't suspicious.
(when (textsec--ipvx-address-p domain)
(throw 'found nil))
(seq-do
(lambda (char)
(when (eq (elt idna-mapping-table char) t)
(throw 'found
(format "Disallowed character%s (#x%x, %s)"
(if (eq (get-char-code-property char 'general-category)
'Cf)
""
(concat ": " (string char)))
char
(char-to-name char)))))
domain)
;; Does IDNA allow it?
(unless (puny-highly-restrictive-domain-p domain)
(throw
'found
(format "`%s' mixes characters from different scripts in suspicious ways"
domain)))
;; Check whether any segment of the domain name is confusable with
;; an ASCII-only segment.
(dolist (elem (split-string domain "\\."))
(when (textsec-ascii-confusable-p elem)
(throw 'found (format "`%s' is confusable with ASCII" elem))))
nil))