From 3230a77d8956338a1a7995a8c20a333c5d39c024 Mon Sep 17 00:00:00 2001 From: Felipe Pena Date: Sun, 30 Mar 2008 12:24:10 +0000 Subject: [PATCH] MFB: Fixed bug #44564 (escapeshellarg removes UTF-8 multi-byte characters) --- ext/standard/exec.c | 4 ++++ sapi/cli/tests/bug44564.phpt | 16 ++++++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 sapi/cli/tests/bug44564.phpt diff --git a/ext/standard/exec.c b/ext/standard/exec.c index 89cb2f5a5b..db4f3f6a39 100644 --- a/ext/standard/exec.c +++ b/ext/standard/exec.c @@ -280,6 +280,8 @@ PHPAPI char *php_escape_shell_cmd(char *str) if (mb_len < 0) { continue; } else if (mb_len > 1) { + memcpy(cmd + y, str + x, mb_len); + y += mb_len; x += mb_len - 1; continue; } @@ -368,6 +370,8 @@ PHPAPI char *php_escape_shell_arg(char *str) if (mb_len < 0) { continue; } else if (mb_len > 1) { + memcpy(cmd + y, str + x, mb_len); + y += mb_len; x += mb_len - 1; continue; } diff --git a/sapi/cli/tests/bug44564.phpt b/sapi/cli/tests/bug44564.phpt new file mode 100644 index 0000000000..da05bbbb15 --- /dev/null +++ b/sapi/cli/tests/bug44564.phpt @@ -0,0 +1,16 @@ +--TEST-- +Bug #44564 (escapeshellarg removes UTF-8 multi-byte characters) +--FILE-- +')); +var_dump(escapeshellarg('f~|;*Þ?')); +var_dump(escapeshellcmd('?€®đæ?')); +var_dump(escapeshellarg('aŊł€')); + +?> +--EXPECT-- +string(13) "f\{o\}\<€\>" +string(10) "'f~|;*Þ?'" +string(13) "\?€®đæ\?" +string(10) "'aŊł€'" -- 2.40.0