aboutsummaryrefslogtreecommitdiffstats
path: root/doc/lispref/text.texi
diff options
context:
space:
mode:
Diffstat (limited to 'doc/lispref/text.texi')
-rw-r--r--doc/lispref/text.texi87
1 files changed, 87 insertions, 0 deletions
diff --git a/doc/lispref/text.texi b/doc/lispref/text.texi
index b9df66dbdb4..37cf376bd53 100644
--- a/doc/lispref/text.texi
+++ b/doc/lispref/text.texi
@@ -59,6 +59,7 @@ the character after point.
59* Decompression:: Dealing with compressed data. 59* Decompression:: Dealing with compressed data.
60* Base 64:: Conversion to or from base 64 encoding. 60* Base 64:: Conversion to or from base 64 encoding.
61* Checksum/Hash:: Computing cryptographic hashes. 61* Checksum/Hash:: Computing cryptographic hashes.
62* Suspicious Text:: Determining whether a string is suspicious.
62* GnuTLS Cryptography:: Cryptographic algorithms imported from GnuTLS. 63* GnuTLS Cryptography:: Cryptographic algorithms imported from GnuTLS.
63* Database:: Interacting with an SQL database. 64* Database:: Interacting with an SQL database.
64* Parsing HTML/XML:: Parsing HTML and XML. 65* Parsing HTML/XML:: Parsing HTML and XML.
@@ -4943,6 +4944,92 @@ It should be somewhat more efficient on larger buffers than
4943@c according to what we find useful. 4944@c according to what we find useful.
4944@end defun 4945@end defun
4945 4946
4947@node Suspicious Text
4948@section Suspicious Text
4949@cindex suspicious text
4950@cindex insecure text
4951@cindex security vulnerabilities in text
4952
4953 Emacs can display text from many external sources, like email and Web
4954sites. Attackers may attempt to confuse the user reading this text by
4955using obfuscated @acronym{URL}s or email addresses, and tricking the
4956user into visiting a web page they didn't intend to visit, or sending
4957an email to the wrong address.
4958
4959This usually involves using characters from scripts that visually look
4960like @acronym{ASCII} characters (i.e., are homoglyphs), but there are
4961also other techniques used, like using bidirectional overrides, or
4962having an @acronym{HTML} link text that says one thing, while the
4963underlying @acronym{URL} points somewhere else.
4964
4965@cindex suspicious text strings
4966To help identify these @dfn{suspicious text strings}, Emacs provides a
4967library to do a number of checks on text. (See
4968@url{https://www.unicode.org/reports/tr39/, UTS #39: Unicode Security
4969Mechanisms} for the rationale behind the checks that are available and
4970more details about them.) Packages that present data that might be
4971suspicious should use this library to flag suspicious text on display.
4972
4973@vindex textsec-check
4974@defun textsec-suspicious-p object type
4975This function is the high-level interface function that packages
4976should use. It respects the @code{textsec-check} user option, which
4977allows the user to disable the checks.
4978
4979This function checks @var{object} (whose data type depends on
4980@var{type}) to see if it looks suspicious when interpreted as a thing
4981of @var{type}. The available types and the corresponding @var{object}
4982data types are:
4983
4984@table @code
4985@item domain
4986Check whether a domain (e.g., @samp{www.gnu.org} looks suspicious.
4987@var{object} should be a string, the domain name.
4988
4989@item url
4990Check whether an @acronym{URL} (e.g., @samp{http://gnu.org/foo/bar})
4991looks suspicious. @var{object} should be a string, the @acronym{URL}
4992to check.
4993
4994@item link
4995Check whether an @acronym{HTML} link (e.g., @samp{<a
4996href='http://gnu.org'>fsf.org</a>} looks suspicious. In this case,
4997@var{object} should be a @code{cons} cell where the @code{car} is the
4998@acronym{URL} string, and the @code{cdr} is the link text. The link
4999is deemed suspicious if the link text contains a domain name, and that
5000domain name points to something other than the @acronym{URL}.
5001
5002@item email-address
5003Check whether an email address (e.g., @samp{foo@@example.org}) looks
5004suspicious. @var{object} should be a string.
5005
5006@item local-address
5007Check whether the local part of an email address (the bit before the
5008@samp{@@} sign) looks suspicious. @var{object} should be a string.
5009
5010@item name
5011Check whether a name (used in an email address header) looks
5012suspicious. @var{object} should be a string.
5013
5014@item email-address-header
5015Check whether a full RFC2822 email address header (e.g.,
5016@samp{=?utf-8?Q?=C3=81?= <foo@@example.com>}) looks suspicious.
5017@var{object} should be a string.
5018@end table
5019
5020If @var{object} is suspicious, this function returns a string that
5021explains why it is suspicious. If @var{object} is not suspicious, the
5022function returns @code{nil}.
5023@end defun
5024
5025@vindex textsec-suspicious@r{ (face)}
5026If the text is suspicious, the application should mark the suspicious
5027text with the @code{textsec-suspicious} face, and make the explanation
5028returned by @code{textsec-suspicious-p} available to the user in some way
5029(for example, in a tooltip). The application might also prompt the
5030user for confirmation before taking any action on a suspicious string
5031(like sending an email to a suspicious email address).
5032
4946@node GnuTLS Cryptography 5033@node GnuTLS Cryptography
4947@section GnuTLS Cryptography 5034@section GnuTLS Cryptography
4948@cindex MD5 checksum 5035@cindex MD5 checksum