diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2017-07-05 19:10:21 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2017-07-05 19:10:21 +0200 |
commit | fda9fafe279d9394ad53313320a949c86f646734 (patch) | |
tree | 3552e44de84460a8d2526f5b9703e70dea1a6259 /shell/ash.c | |
parent | 6798486141057f7989c0e59d5f645aba87a58f62 (diff) | |
download | busybox-w32-fda9fafe279d9394ad53313320a949c86f646734.tar.gz busybox-w32-fda9fafe279d9394ad53313320a949c86f646734.tar.bz2 busybox-w32-fda9fafe279d9394ad53313320a949c86f646734.zip |
ash: fix matching of unicode greek letter rho (cf 81) and similar cases
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'shell/ash.c')
-rw-r--r-- | shell/ash.c | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/shell/ash.c b/shell/ash.c index 6d46e3719..e5fdd1646 100644 --- a/shell/ash.c +++ b/shell/ash.c | |||
@@ -5913,6 +5913,7 @@ rmescapes(char *str, int flag) | |||
5913 | while (*p) { | 5913 | while (*p) { |
5914 | if ((unsigned char)*p == CTLQUOTEMARK) { | 5914 | if ((unsigned char)*p == CTLQUOTEMARK) { |
5915 | // Note: both inquotes and protect_against_glob only affect whether | 5915 | // Note: both inquotes and protect_against_glob only affect whether |
5916 | // CTLESC,<ch> gets converted to <ch> or to \<ch> | ||
5916 | inquotes = ~inquotes; | 5917 | inquotes = ~inquotes; |
5917 | p++; | 5918 | p++; |
5918 | protect_against_glob = globbing; | 5919 | protect_against_glob = globbing; |
@@ -5925,7 +5926,27 @@ rmescapes(char *str, int flag) | |||
5925 | ash_msg_and_raise_error("CTLESC at EOL (shouldn't happen)"); | 5926 | ash_msg_and_raise_error("CTLESC at EOL (shouldn't happen)"); |
5926 | #endif | 5927 | #endif |
5927 | if (protect_against_glob) { | 5928 | if (protect_against_glob) { |
5928 | *q++ = '\\'; | 5929 | /* |
5930 | * We used to trust glob() and fnmatch() to eat | ||
5931 | * superfluous escapes (\z where z has no | ||
5932 | * special meaning anyway). But this causes | ||
5933 | * bugs such as string of one greek letter rho | ||
5934 | * (unicode-encoded as two bytes 'cf,81") | ||
5935 | * getting encoded as "cf,CTLESC,81" | ||
5936 | * and here, converted to "cf,\,81" - | ||
5937 | * which does not go well with some flavors | ||
5938 | * of fnmatch() in unicode locales. | ||
5939 | * | ||
5940 | * Lets add "\" only on the chars which need it. | ||
5941 | */ | ||
5942 | if (*p == '*' | ||
5943 | || *p == '?' | ||
5944 | || *p == '[' | ||
5945 | /* || *p == ']' maybe also this? */ | ||
5946 | || *p == '\\' | ||
5947 | ) { | ||
5948 | *q++ = '\\'; | ||
5949 | } | ||
5929 | } | 5950 | } |
5930 | } else if (*p == '\\' && !inquotes) { | 5951 | } else if (*p == '\\' && !inquotes) { |
5931 | /* naked back slash */ | 5952 | /* naked back slash */ |