Mercurial > emacs
changeset 72267:698c7a5192be
(Formatting Strings): Warn against arbitrary strings as first arg to `format'.
author | Eli Zaretskii <eliz@gnu.org> |
---|---|
date | Fri, 04 Aug 2006 10:42:14 +0000 |
parents | 436c014d941c |
children | c3d7d4008d2d |
files | lispref/strings.texi |
diffstat | 1 files changed, 11 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/lispref/strings.texi Fri Aug 04 02:50:10 2006 +0000 +++ b/lispref/strings.texi Fri Aug 04 10:42:14 2006 +0000 @@ -701,7 +701,6 @@ The characters in @var{string}, other than the format specifications, are copied directly into the output; if they have text properties, -these are copied into the output also. @end defun @cindex @samp{%} in format @@ -719,6 +718,17 @@ @end group @end example + Since @code{format} interprets @samp{%} characters as format +specifications, you should @emph{never} pass an arbitrary string as +the first argument. This is particularly true when the string is +generated by some Lisp code. Unless the string is @emph{known} to +never include any @samp{%} characters, pass @code{"%s"}, described +below, as the first argument, and the string as the second, like this: + +@example + (format "%s" @var{arbitrary-string}) +@end example + If @var{string} contains more than one format specification, the format specifications correspond to successive values from @var{objects}. Thus, the first format specification in @var{string}