From 55c1670bc52c924d80c72e55bf3864023749be29 Mon Sep 17 00:00:00 2001 From: Lars Ingebrigtsen Date: Thu, 20 Jan 2022 14:33:36 +0100 Subject: [PATCH] Rename the textsec-check function to textsec-suspicious-p * lisp/net/shr.el (shr-tag-a): * lisp/international/textsec-check.el (textsec-suspicious-p): * lisp/gnus/message.el (message-send-mail): * lisp/gnus/gnus-art.el (article--check-suspicious-addresses): * etc/NEWS (like): * doc/lispref/text.texi (Suspicious Text): (Suspicious Text): Rename the textsec-check function to textsec-suspicious-p. --- doc/lispref/text.texi | 4 ++-- etc/NEWS | 2 +- lisp/gnus/gnus-art.el | 2 +- lisp/gnus/message.el | 4 ++-- lisp/international/textsec-check.el | 4 ++-- lisp/net/shr.el | 13 +++++++------ 6 files changed, 15 insertions(+), 14 deletions(-) diff --git a/doc/lispref/text.texi b/doc/lispref/text.texi index 097c1de4449..37cf376bd53 100644 --- a/doc/lispref/text.texi +++ b/doc/lispref/text.texi @@ -4971,7 +4971,7 @@ more details about them.) Packages that present data that might be suspicious should use this library to flag suspicious text on display. @vindex textsec-check -@defun textsec-check object type +@defun textsec-suspicious-p object type This function is the high-level interface function that packages should use. It respects the @code{textsec-check} user option, which allows the user to disable the checks. @@ -5025,7 +5025,7 @@ function returns @code{nil}. @vindex textsec-suspicious@r{ (face)} If the text is suspicious, the application should mark the suspicious text with the @code{textsec-suspicious} face, and make the explanation -returned by @code{textsec-check} available to the user in some way +returned by @code{textsec-suspicious-p} available to the user in some way (for example, in a tooltip). The application might also prompt the user for confirmation before taking any action on a suspicious string (like sending an email to a suspicious email address). diff --git a/etc/NEWS b/etc/NEWS index 17ddd6bc186..5e78730bc88 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -1029,7 +1029,7 @@ suspicious address. If this variable is nil, these checks aren't performed. +++ -*** New function 'textsec-check'. +*** New function 'textsec-suspicious-p'. This is the main function Emacs applications should be using to check whether a string is suspicious. It heeds the 'textsec-check' user option. diff --git a/lisp/gnus/gnus-art.el b/lisp/gnus/gnus-art.el index 8e46685e25f..9bb74e80857 100644 --- a/lisp/gnus/gnus-art.el +++ b/lisp/gnus/gnus-art.el @@ -2661,7 +2661,7 @@ If PROMPT (the prefix), prompt for a coding system to use." (dolist (header (mail-header-parse-addresses addresses t)) (when-let* ((address (car (ignore-errors (mail-header-parse-address header)))) - (warning (textsec-check address 'email-address))) + (warning (textsec-suspicious-p address 'email-address))) (goto-char (point-min)) (while (search-forward address nil t) (put-text-property (match-beginning 0) (match-end 0) diff --git a/lisp/gnus/message.el b/lisp/gnus/message.el index c1afe3043ef..3cd1b7eefe8 100644 --- a/lisp/gnus/message.el +++ b/lisp/gnus/message.el @@ -4907,8 +4907,8 @@ If you always want Gnus to send messages in one piece, set (let ((addr (message-fetch-field hdr))) (when (stringp addr) (dolist (address (mail-header-parse-addresses addr t)) - (when-let ((warning (textsec-check address - 'email-address-header))) + (when-let ((warning (textsec-suspicious-p + address 'email-address-header))) (unless (y-or-n-p (format "Suspicious address: %s; send anyway?" warning)) diff --git a/lisp/international/textsec-check.el b/lisp/international/textsec-check.el index e3662e0d85c..567ef73feb2 100644 --- a/lisp/international/textsec-check.el +++ b/lisp/international/textsec-check.el @@ -39,8 +39,8 @@ If nil, these checks are disabled." "Face used to highlight suspicious strings.") ;;;###autoload -(defun textsec-check (object type) - "Test whether OBJECT is suspicious for use as TYPE. +(defun textsec-suspicious-p (object type) + "Say whether OBJECT is suspicious for use as TYPE. If OBJECT is suspicious, return a string explaining the reason for considering it suspicious, otherwise return nil. diff --git a/lisp/net/shr.el b/lisp/net/shr.el index 79a8e9ba262..ff14acfda70 100644 --- a/lisp/net/shr.el +++ b/lisp/net/shr.el @@ -1469,12 +1469,13 @@ ones, in case fg and bg are nil." (when url (shr-urlify (or shr-start start) (shr-expand-url url) title) ;; Check whether the URL is suspicious. - (when-let ((warning (or (textsec-check (shr-expand-url url) 'url) - (textsec-check (cons (shr-expand-url url) - (buffer-substring - (or shr-start start) - (point))) - 'link)))) + (when-let ((warning (or (textsec-suspicious-p + (shr-expand-url url) 'url) + (textsec-suspicious-p + (cons (shr-expand-url url) + (buffer-substring (or shr-start start) + (point))) + 'link)))) (add-text-properties (or shr-start start) (point) (list 'face '(shr-link textsec-suspicious))) (insert (propertize "⚠️" 'help-echo warning)))))) -- 2.39.5