summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnatol Belski <ab@php.net>2018-11-16 23:22:19 +0100
committerAnatol Belski <ab@php.net>2018-11-16 23:22:19 +0100
commit00c08a2e4a8f4294744c5ba77792e5aa6e91e920 (patch)
tree3351cf5ddc578b74053b8ade2c666f5703993915
parentdee5a450d9b7f7b03f012dd1912cc0a3dcb0482c (diff)
parenta7e9790969952c0574d8708277abfd25d12f58e5 (diff)
downloadphp-git-00c08a2e4a8f4294744c5ba77792e5aa6e91e920.tar.gz
Merge branch 'PHP-7.2' into PHP-7.3
* PHP-7.2: Fixed bug #77111 php-win.exe corrupts unicode symbols from cli parameters
-rw-r--r--sapi/cli/config.w321
-rw-r--r--sapi/cli/php_cli.c9
-rw-r--r--sapi/cli/tests/argv_mb_bug77111.phpt42
3 files changed, 47 insertions, 5 deletions
diff --git a/sapi/cli/config.w32 b/sapi/cli/config.w32
index 155b2ce838..26c53f7808 100644
--- a/sapi/cli/config.w32
+++ b/sapi/cli/config.w32
@@ -22,4 +22,5 @@ if (PHP_CLI == "yes") {
if (PHP_CLI_WIN32 == "yes") {
SAPI('cli_win32', 'cli_win32.c php_cli_process_title.c ps_title.c', 'php-win.exe', '/DZEND_ENABLE_STATIC_TSRMLS_CACHE=1');
ADD_FLAG("LDFLAGS_CLI_WIN32", "/stack:67108864");
+ ADD_FLAG("LIBS_CLI_WIN32", "shell32.lib");
}
diff --git a/sapi/cli/php_cli.c b/sapi/cli/php_cli.c
index a36ea1893a..3b053e223a 100644
--- a/sapi/cli/php_cli.c
+++ b/sapi/cli/php_cli.c
@@ -637,7 +637,7 @@ static int cli_seek_file_begin(zend_file_handle *file_handle, char *script_file,
/* }}} */
/*{{{ php_cli_win32_ctrl_handler */
-#if defined(PHP_WIN32) && !defined(PHP_CLI_WIN32_NO_CONSOLE)
+#if defined(PHP_WIN32)
BOOL WINAPI php_cli_win32_ctrl_handler(DWORD sig)
{
(void)php_win32_cp_cli_do_restore(orig_cp);
@@ -1190,12 +1190,11 @@ int main(int argc, char *argv[])
# ifdef PHP_CLI_WIN32_NO_CONSOLE
int argc = __argc;
char **argv = __argv;
-# else
+# endif
int num_args;
wchar_t **argv_wide;
char **argv_save = argv;
BOOL using_wide_argv = 0;
-# endif
#endif
int c;
@@ -1365,7 +1364,7 @@ exit_loop:
}
module_started = 1;
-#if defined(PHP_WIN32) && !defined(PHP_CLI_WIN32_NO_CONSOLE)
+#if defined(PHP_WIN32)
php_win32_cp_cli_setup();
orig_cp = (php_win32_cp_get_orig())->id;
/* Ignore the delivered argv and argc, read from W API. This place
@@ -1411,7 +1410,7 @@ out:
tsrm_shutdown();
#endif
-#if defined(PHP_WIN32) && !defined(PHP_CLI_WIN32_NO_CONSOLE)
+#if defined(PHP_WIN32)
(void)php_win32_cp_cli_restore();
if (using_wide_argv) {
diff --git a/sapi/cli/tests/argv_mb_bug77111.phpt b/sapi/cli/tests/argv_mb_bug77111.phpt
new file mode 100644
index 0000000000..e21cc07678
--- /dev/null
+++ b/sapi/cli/tests/argv_mb_bug77111.phpt
@@ -0,0 +1,42 @@
+--TEST--
+Bug #77111 php-win.exe corrupts unicode symbols from cli parameters
+--SKIPIF--
+<?php
+include "skipif.inc";
+
+if (strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN') {
+ die("skip this test is for Windows platforms only");
+}
+
+$php = dirname(getenv('TEST_PHP_EXECUTABLE')) . DIRECTORY_SEPARATOR . "php-win.exe";
+if (!file_exists($php)) {
+ die("skip php-win.exe doesn't exist");
+}
+
+?>
+--FILE--
+<?php
+
+$php = dirname(getenv('TEST_PHP_EXECUTABLE')) . DIRECTORY_SEPARATOR . "php-win.exe";
+
+$out_fl = dirname(__FILE__) . "\\argv_bug77111.txt";
+
+$argv_fl = dirname(__FILE__) . DIRECTORY_SEPARATOR . "argv_test.php";
+file_put_contents($argv_fl, "<?php file_put_contents('$out_fl', implode(' ', array_slice(\$argv, 1))); ?>");
+
+`$php -n $argv_fl Ästhetik Æstetik Esthétique Estética Эстетика`;
+var_dump(file_get_contents($out_fl));
+
+?>
+==DONE==
+--CLEAN--
+<?php
+$out_fl = dirname(__FILE__) . "\\argv_bug77111.txt";
+$argv_fl = dirname(__FILE__) . DIRECTORY_SEPARATOR . "argv_test.php";
+unlink($argv_fl);
+unlink($out_fl);
+?>
+--EXPECTF--
+string(57) "Ästhetik Æstetik Esthétique Estética Эстетика"
+==DONE==
+