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

index 2c38a1a34aee9adc363f1b291adbd93dd46d7b46..2906f87d1d7dd01f979276fb4fcb4e8e36249133 100644 (file)
@@ -279,6 +279,8 @@ 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;
                }
@@ -361,6 +363,8 @@ 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Ŋł€'"