aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--shell/ash.c23
-rw-r--r--shell/ash_test/ash-quoting/unicode_8x_chars.right6
-rwxr-xr-xshell/ash_test/ash-quoting/unicode_8x_chars.tests28
-rw-r--r--shell/hush_test/hush-quoting/unicode_8x_chars.right6
-rwxr-xr-xshell/hush_test/hush-quoting/unicode_8x_chars.tests28
5 files changed, 90 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 */
diff --git a/shell/ash_test/ash-quoting/unicode_8x_chars.right b/shell/ash_test/ash-quoting/unicode_8x_chars.right
new file mode 100644
index 000000000..7780b88b4
--- /dev/null
+++ b/shell/ash_test/ash-quoting/unicode_8x_chars.right
@@ -0,0 +1,6 @@
1ok
2ok
3ok
4ok
5ok
6ok
diff --git a/shell/ash_test/ash-quoting/unicode_8x_chars.tests b/shell/ash_test/ash-quoting/unicode_8x_chars.tests
new file mode 100755
index 000000000..1258745ec
--- /dev/null
+++ b/shell/ash_test/ash-quoting/unicode_8x_chars.tests
@@ -0,0 +1,28 @@
1# Unicode: cf 80
2case π in
3( "π" ) echo ok ;;
4( * ) echo WRONG ;;
5esac
6# Unicode: cf 81
7case ρ in
8( "ρ" ) echo ok ;;
9( * ) echo WRONG ;;
10esac
11# Unicode: cf 82
12case ς in
13( "ς" ) echo ok ;;
14( * ) echo WRONG ;;
15esac
16
17case "π" in
18( π ) echo ok ;;
19( * ) echo WRONG ;;
20esac
21case "ρ" in
22( ρ ) echo ok ;;
23( * ) echo WRONG ;;
24esac
25case "ς" in
26( ς ) echo ok ;;
27( * ) echo WRONG ;;
28esac
diff --git a/shell/hush_test/hush-quoting/unicode_8x_chars.right b/shell/hush_test/hush-quoting/unicode_8x_chars.right
new file mode 100644
index 000000000..7780b88b4
--- /dev/null
+++ b/shell/hush_test/hush-quoting/unicode_8x_chars.right
@@ -0,0 +1,6 @@
1ok
2ok
3ok
4ok
5ok
6ok
diff --git a/shell/hush_test/hush-quoting/unicode_8x_chars.tests b/shell/hush_test/hush-quoting/unicode_8x_chars.tests
new file mode 100755
index 000000000..1258745ec
--- /dev/null
+++ b/shell/hush_test/hush-quoting/unicode_8x_chars.tests
@@ -0,0 +1,28 @@
1# Unicode: cf 80
2case π in
3( "π" ) echo ok ;;
4( * ) echo WRONG ;;
5esac
6# Unicode: cf 81
7case ρ in
8( "ρ" ) echo ok ;;
9( * ) echo WRONG ;;
10esac
11# Unicode: cf 82
12case ς in
13( "ς" ) echo ok ;;
14( * ) echo WRONG ;;
15esac
16
17case "π" in
18( π ) echo ok ;;
19( * ) echo WRONG ;;
20esac
21case "ρ" in
22( ρ ) echo ok ;;
23( * ) echo WRONG ;;
24esac
25case "ς" in
26( ς ) echo ok ;;
27( * ) echo WRONG ;;
28esac