Skip to content

Commit 00c08a2

Browse files
committed
Merge branch 'PHP-7.2' into PHP-7.3
* PHP-7.2: Fixed bug #77111 php-win.exe corrupts unicode symbols from cli parameters
2 parents dee5a45 + a7e9790 commit 00c08a2

File tree

3 files changed

+47
-5
lines changed

3 files changed

+47
-5
lines changed

sapi/cli/config.w32

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,5 @@ if (PHP_CLI == "yes") {
2222
if (PHP_CLI_WIN32 == "yes") {
2323
SAPI('cli_win32', 'cli_win32.c php_cli_process_title.c ps_title.c', 'php-win.exe', '/DZEND_ENABLE_STATIC_TSRMLS_CACHE=1');
2424
ADD_FLAG("LDFLAGS_CLI_WIN32", "/stack:67108864");
25+
ADD_FLAG("LIBS_CLI_WIN32", "shell32.lib");
2526
}

sapi/cli/php_cli.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -637,7 +637,7 @@ static int cli_seek_file_begin(zend_file_handle *file_handle, char *script_file,
637637
/* }}} */
638638

639639
/*{{{ php_cli_win32_ctrl_handler */
640-
#if defined(PHP_WIN32) && !defined(PHP_CLI_WIN32_NO_CONSOLE)
640+
#if defined(PHP_WIN32)
641641
BOOL WINAPI php_cli_win32_ctrl_handler(DWORD sig)
642642
{
643643
(void)php_win32_cp_cli_do_restore(orig_cp);
@@ -1190,12 +1190,11 @@ int main(int argc, char *argv[])
11901190
# ifdef PHP_CLI_WIN32_NO_CONSOLE
11911191
int argc = __argc;
11921192
char **argv = __argv;
1193-
# else
1193+
# endif
11941194
int num_args;
11951195
wchar_t **argv_wide;
11961196
char **argv_save = argv;
11971197
BOOL using_wide_argv = 0;
1198-
# endif
11991198
#endif
12001199

12011200
int c;
@@ -1365,7 +1364,7 @@ int main(int argc, char *argv[])
13651364
}
13661365
module_started = 1;
13671366

1368-
#if defined(PHP_WIN32) && !defined(PHP_CLI_WIN32_NO_CONSOLE)
1367+
#if defined(PHP_WIN32)
13691368
php_win32_cp_cli_setup();
13701369
orig_cp = (php_win32_cp_get_orig())->id;
13711370
/* Ignore the delivered argv and argc, read from W API. This place
@@ -1411,7 +1410,7 @@ int main(int argc, char *argv[])
14111410
tsrm_shutdown();
14121411
#endif
14131412

1414-
#if defined(PHP_WIN32) && !defined(PHP_CLI_WIN32_NO_CONSOLE)
1413+
#if defined(PHP_WIN32)
14151414
(void)php_win32_cp_cli_restore();
14161415

14171416
if (using_wide_argv) {

sapi/cli/tests/argv_mb_bug77111.phpt

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
--TEST--
2+
Bug #77111 php-win.exe corrupts unicode symbols from cli parameters
3+
--SKIPIF--
4+
<?php
5+
include "skipif.inc";
6+
7+
if (strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN') {
8+
die("skip this test is for Windows platforms only");
9+
}
10+
11+
$php = dirname(getenv('TEST_PHP_EXECUTABLE')) . DIRECTORY_SEPARATOR . "php-win.exe";
12+
if (!file_exists($php)) {
13+
die("skip php-win.exe doesn't exist");
14+
}
15+
16+
?>
17+
--FILE--
18+
<?php
19+
20+
$php = dirname(getenv('TEST_PHP_EXECUTABLE')) . DIRECTORY_SEPARATOR . "php-win.exe";
21+
22+
$out_fl = dirname(__FILE__) . "\\argv_bug77111.txt";
23+
24+
$argv_fl = dirname(__FILE__) . DIRECTORY_SEPARATOR . "argv_test.php";
25+
file_put_contents($argv_fl, "<?php file_put_contents('$out_fl', implode(' ', array_slice(\$argv, 1))); ?>");
26+
27+
`$php -n $argv_fl Ästhetik Æstetik Esthétique Estética Эстетика`;
28+
var_dump(file_get_contents($out_fl));
29+
30+
?>
31+
==DONE==
32+
--CLEAN--
33+
<?php
34+
$out_fl = dirname(__FILE__) . "\\argv_bug77111.txt";
35+
$argv_fl = dirname(__FILE__) . DIRECTORY_SEPARATOR . "argv_test.php";
36+
unlink($argv_fl);
37+
unlink($out_fl);
38+
?>
39+
--EXPECTF--
40+
string(57) "Ästhetik Æstetik Esthétique Estética Эстетика"
41+
==DONE==
42+

0 commit comments

Comments
 (0)