]> git.eshelyaron.com Git - emacs.git/commitdiff
Make textsec-link-suspicious-p have fewer false positives
authorLars Ingebrigtsen <larsi@gnus.org>
Thu, 20 Jan 2022 11:37:31 +0000 (12:37 +0100)
committerLars Ingebrigtsen <larsi@gnus.org>
Thu, 20 Jan 2022 11:37:31 +0000 (12:37 +0100)
* lisp/international/textsec.el (textsec-link-suspicious-p):
Attempt to improve the domain-guessing logic.

lisp/international/textsec.el

index ba39c44e857785cfe71011d2fc2b771e189d4824..db13839e90e3a2899cd7bc08c4fa88a86da7a6c8 100644 (file)
@@ -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))