From 6d61a3859ecdcd2813a5d2f06393208fa2feb399 Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Wed, 2 Aug 2006 17:16:37 +0000 Subject: 22578: ensure HISTCHARS/histchars never contains non-ASCII characters --- ChangeLog | 3 +++ Doc/Zsh/params.yo | 4 ++++ README | 5 +++++ Src/params.c | 19 +++++++++++++++---- 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 + * 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) )( 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 = '#'; -- cgit 1.4.1