about summary refs log tree commit diff
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2006-08-02 17:16:37 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2006-08-02 17:16:37 +0000
commit6d61a3859ecdcd2813a5d2f06393208fa2feb399 (patch)
tree69b99bde965279a5d0c35f4ee86b2db8006368ea
parent21c83849a91360d8af60fd253c4a808bd720f07c (diff)
downloadzsh-6d61a3859ecdcd2813a5d2f06393208fa2feb399.tar.gz
zsh-6d61a3859ecdcd2813a5d2f06393208fa2feb399.tar.xz
zsh-6d61a3859ecdcd2813a5d2f06393208fa2feb399.zip
22578: ensure HISTCHARS/histchars never contains non-ASCII characters
-rw-r--r--ChangeLog3
-rw-r--r--Doc/Zsh/params.yo4
-rw-r--r--README5
-rw-r--r--Src/params.c19
4 files changed, 27 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index 357a7091a..4621f1314 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2006-08-02  Peter Stephenson  <pws@csr.com>
 
+	* 22578: README, Doc/Zsh/params.yo, Src/params.c: ensure
+	HISTCHARS/histchars never contains non-ASCII characters.
+
 	* unposted: Functions/Zle/history-beginning-search-menu,
 	Doc/Zsh/params.yo: yet more tweaks I'm too embarrassed to post:
 	^ also needs quoting; clear display on first non-digit character;
diff --git a/Doc/Zsh/params.yo b/Doc/Zsh/params.yo
index a0e520274..30bf1174c 100644
--- a/Doc/Zsh/params.yo
+++ b/Doc/Zsh/params.yo
@@ -803,6 +803,10 @@ mechanism.  The first character signals the start of a history
 expansion (default `tt(!)').  The second character signals the
 start of a quick history substitution (default `tt(^)').  The third
 character is the comment character (default `tt(#)').
+
+The characters must be in the ASCII character set; any attempt to set
+tt(histchars) to characters with a locale-dependent meaning will be
+rejected with an error message.
 )
 vindex(HISTCHARS)
 item(tt(HISTCHARS) <S> <Z>)(
diff --git a/README b/README
index c2d4dff88..81f868f02 100644
--- a/README
+++ b/README
@@ -81,6 +81,11 @@ previous value was observed to be large enough that crashes still occurred
 on some fairly common PC configurations.  This change is only likely to
 affect some highly specialised uses of the shell.
 
+The variables HISTCHARS and histchars now reject any attempt to
+set non-ASCII characters for history or comments.  Multibyte characters
+have never worked and the most consistent change was to restrict the
+set to portable characters only.
+
 Documentation
 -------------
 
diff --git a/Src/params.c b/Src/params.c
index 17ce2c54d..e3040fb7f 100644
--- a/Src/params.c
+++ b/Src/params.c
@@ -3548,10 +3548,21 @@ void
 histcharssetfn(UNUSED(Param pm), char *x)
 {
     if (x) {
-	bangchar = x[0];
-	hatchar = (bangchar) ? x[1] : '\0';
-	hashchar = (hatchar) ? x[2] : '\0';
-	zsfree(x);
+	int len, i;
+
+	unmetafy(x, &len);
+	if (len > 3)
+	    len = 3;
+	for (i = 0; i < len; i++) {
+	    if (!isascii(STOUC(x[i]))) {
+		zwarn("HISTCHARS can only contain ASCII characters");
+		return;
+	    }
+	}
+	bangchar = len ? STOUC(x[0]) : '\0';
+	hatchar =  len > 1 ? STOUC(x[1]) : '\0';
+	hashchar = len > 2 ? STOUC(x[2]) : '\0';
+	free(x);
     } else {
 	bangchar = '!';
 	hashchar = '#';