]> granicus.if.org Git - php/commitdiff
MFB: Fixed bug #44564 (escapeshellarg removes UTF-8 multi-byte characters)
authorFelipe Pena <felipe@php.net>
Sun, 30 Mar 2008 12:24:10 +0000 (12:24 +0000)
committerFelipe Pena <felipe@php.net>
Sun, 30 Mar 2008 12:24:10 +0000 (12:24 +0000)
ext/standard/exec.c
sapi/cli/tests/bug44564.phpt [new file with mode: 0644]

index 89cb2f5a5b26f7b1e7e67412f84dc1b9dcf891d8..db4f3f6a390b7417b060dbb69706e7a481cd6690 100644 (file)
@@ -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 (file)
index 0000000..da05bbb
--- /dev/null
@@ -0,0 +1,16 @@
+--TEST--
+Bug #44564 (escapeshellarg removes UTF-8 multi-byte characters)
+--FILE--
+<?php
+
+var_dump(escapeshellcmd('f{o}<€>'));
+var_dump(escapeshellarg('f~|;*Þ?'));
+var_dump(escapeshellcmd('?€®đæ?'));
+var_dump(escapeshellarg('aŊł€'));
+
+?>
+--EXPECT--
+string(13) "f\{o\}\<€\>"
+string(10) "'f~|;*Þ?'"
+string(13) "\?€®đæ\?"
+string(10) "'aŊł€'"