From 5a64286d6a3ceaa5ca114ba5987f6698189647f5 Mon Sep 17 00:00:00 2001 From: Lars Ingebrigtsen Date: Thu, 20 Jan 2022 12:37:31 +0100 Subject: [PATCH] Make textsec-link-suspicious-p have fewer false positives * lisp/international/textsec.el (textsec-link-suspicious-p): Attempt to improve the domain-guessing logic. --- lisp/international/textsec.el | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/lisp/international/textsec.el b/lisp/international/textsec.el index ba39c44e857..db13839e90e 100644 --- a/lisp/international/textsec.el +++ b/lisp/international/textsec.el @@ -398,13 +398,14 @@ when the link text looks like an URL itself, but doesn't lead to the same domain as the URL." (let* ((url (car link)) (text (string-trim (cdr link))) - (text-bits (seq-filter - (lambda (bit) - (and (string-match-p "\\`[^.]+\\.[^.]+.*\\'" bit) - ;; All-numerical texts are probably not - ;; suspicious (but what about IP addresses?). - (not (string-match-p "\\`[0-9.]+\\'" bit)))) - (split-string text)))) + (text-bits + (seq-filter + (lambda (bit) + (and (string-match-p "\\`[^.[:punct:]]+\\.[^.[:punct:]]+\\'" bit) + ;; All-numerical texts are probably not + ;; suspicious (but what about IP addresses?). + (not (string-match-p "\\`[0-9.]+\\'" bit)))) + (split-string text)))) (when text-bits (setq text-bits (seq-map (lambda (string) (if (not (string-match-p "\\`[^:]+:" string)) -- 2.39.2