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.
@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).
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.
(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)
(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))
"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.
(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))))))