summaryrefslogtreecommitdiff
path: root/sapi/cli
diff options
context:
space:
mode:
authorAnthony Ferrara <ircmaxell@gmail.com>2012-09-04 10:29:22 -0400
committerAnthony Ferrara <ircmaxell@gmail.com>2012-09-04 10:29:22 -0400
commit824f1f45818096eff0e022ba2a1cbc2071343c9a (patch)
tree821b106513b7835d8e7fad8960446167142028f9 /sapi/cli
parente05413ca594ff10fd93d40429cb598c2e109edf4 (diff)
parent4b206126aca2ad9181abe65d70367680a4bc4c03 (diff)
downloadphp-git-824f1f45818096eff0e022ba2a1cbc2071343c9a.tar.gz
Merge remote branch 'upstream/master' into hash_password
* upstream/master: (393 commits) forked two tests for windows Fixed bug #50997 (SOAP Error when trying to submit 2nd Element of a choice) Fixed bug #50997 (SOAP Error when trying to submit 2nd Element of a choice). Fixed bug #50997 (SOAP Error when trying to submit 2nd Element of a choice). Fixed bug #50997 (SOAP Error when trying to submit 2nd Element of a choice) Fixed bug #50997 (SOAP Error when trying to submit 2nd Element of a choice) Bug #49510: Boolean validation fails with FILTER_NULL_ON_FAILURE with empty string or false Implemented ReflectionFunction::isGenerator() Allow null as a default value for length in mb_substr() and mb_strcut() Allow null as a default value for length in mb_substr() and mb_strcut() folder Initializing optional argument description in assert() Initializing optional argument description in assert() Fix test failed due to new Token T_YIELD fix NEWS Fix leak when yielding array as key Drop obsolete test Remove extra blank in notice message, should act as same as vm Fixed bug #62987 (Assigning to ArrayObject[null][something] overrides all undefined variables) assert() user message ...
Diffstat (limited to 'sapi/cli')
-rw-r--r--sapi/cli/config.m42
-rw-r--r--sapi/cli/php_cli.c6
-rw-r--r--sapi/cli/php_cli_server.c64
-rw-r--r--sapi/cli/php_http_parser.h5
-rw-r--r--sapi/cli/tests/php_cli_server.inc2
-rw-r--r--sapi/cli/tests/php_cli_server_011.phpt41
6 files changed, 43 insertions, 77 deletions
diff --git a/sapi/cli/config.m4 b/sapi/cli/config.m4
index 77fc5e9551..cdfa1f7daf 100644
--- a/sapi/cli/config.m4
+++ b/sapi/cli/config.m4
@@ -44,5 +44,7 @@ if test "$PHP_CLI" != "no"; then
PHP_SUBST(BUILD_CLI)
PHP_OUTPUT(sapi/cli/php.1)
+
+ PHP_INSTALL_HEADERS([sapi/cli/cli.h])
fi
AC_MSG_RESULT($PHP_CLI)
diff --git a/sapi/cli/php_cli.c b/sapi/cli/php_cli.c
index 2cdd1aac6d..f9bf3ee60b 100644
--- a/sapi/cli/php_cli.c
+++ b/sapi/cli/php_cli.c
@@ -1167,15 +1167,15 @@ static int do_cli(int argc, char **argv TSRMLS_DC) /* {{{ */
} zend_end_try();
out:
- if (exit_status == 0) {
- exit_status = EG(exit_status);
- }
if (request_started) {
php_request_shutdown((void *) 0);
}
if (translated_path) {
free(translated_path);
}
+ if (exit_status == 0) {
+ exit_status = EG(exit_status);
+ }
return exit_status;
err:
sapi_deactivate(TSRMLS_C);
diff --git a/sapi/cli/php_cli_server.c b/sapi/cli/php_cli_server.c
index 876c57a34d..89262e863d 100644
--- a/sapi/cli/php_cli_server.c
+++ b/sapi/cli/php_cli_server.c
@@ -1618,7 +1618,11 @@ static int php_cli_server_client_read_request(php_cli_server_client *client, cha
client->parser.data = client;
nbytes_consumed = php_http_parser_execute(&client->parser, &settings, buf, nbytes_read);
if (nbytes_consumed != nbytes_read) {
- *errstr = estrdup("Malformed HTTP request");
+ if (buf[0] & 0x80 /* SSLv2 */ || buf[0] == 0x16 /* SSLv3/TLSv1 */) {
+ *errstr = estrdup("Unsupported SSL request");
+ } else {
+ *errstr = estrdup("Malformed HTTP request");
+ }
return -1;
}
if (client->current_header_name) {
@@ -1944,40 +1948,38 @@ static int php_cli_server_request_shutdown(php_cli_server *server, php_cli_serve
static int php_cli_server_dispatch_router(php_cli_server *server, php_cli_server_client *client TSRMLS_DC) /* {{{ */
{
int decline = 0;
- if (!php_handle_special_queries(TSRMLS_C)) {
- zend_file_handle zfd;
- char *old_cwd;
-
- ALLOCA_FLAG(use_heap)
- old_cwd = do_alloca(MAXPATHLEN, use_heap);
- old_cwd[0] = '\0';
- php_ignore_value(VCWD_GETCWD(old_cwd, MAXPATHLEN - 1));
-
- zfd.type = ZEND_HANDLE_FILENAME;
- zfd.filename = server->router;
- zfd.handle.fp = NULL;
- zfd.free_filename = 0;
- zfd.opened_path = NULL;
-
- zend_try {
- zval *retval = NULL;
- if (SUCCESS == zend_execute_scripts(ZEND_REQUIRE TSRMLS_CC, &retval, 1, &zfd)) {
- if (retval) {
- decline = Z_TYPE_P(retval) == IS_BOOL && !Z_LVAL_P(retval);
- zval_ptr_dtor(&retval);
- }
- } else {
- decline = 1;
+ zend_file_handle zfd;
+ char *old_cwd;
+
+ ALLOCA_FLAG(use_heap)
+ old_cwd = do_alloca(MAXPATHLEN, use_heap);
+ old_cwd[0] = '\0';
+ php_ignore_value(VCWD_GETCWD(old_cwd, MAXPATHLEN - 1));
+
+ zfd.type = ZEND_HANDLE_FILENAME;
+ zfd.filename = server->router;
+ zfd.handle.fp = NULL;
+ zfd.free_filename = 0;
+ zfd.opened_path = NULL;
+
+ zend_try {
+ zval *retval = NULL;
+ if (SUCCESS == zend_execute_scripts(ZEND_REQUIRE TSRMLS_CC, &retval, 1, &zfd)) {
+ if (retval) {
+ decline = Z_TYPE_P(retval) == IS_BOOL && !Z_LVAL_P(retval);
+ zval_ptr_dtor(&retval);
}
- } zend_end_try();
-
- if (old_cwd[0] != '\0') {
- php_ignore_value(VCWD_CHDIR(old_cwd));
+ } else {
+ decline = 1;
}
+ } zend_end_try();
- free_alloca(old_cwd, use_heap);
+ if (old_cwd[0] != '\0') {
+ php_ignore_value(VCWD_CHDIR(old_cwd));
}
+ free_alloca(old_cwd, use_heap);
+
return decline;
}
/* }}} */
@@ -2403,7 +2405,7 @@ int do_cli_server(int argc, char **argv TSRMLS_DC) /* {{{ */
php_localtime_r(&tv.tv_sec, &tm);
php_asctime_r(&tm, buf);
printf("PHP %s Development Server started at %s"
- "Listening on %s\n"
+ "Listening on http://%s\n"
"Document root is %s\n"
"Press Ctrl-C to quit.\n",
PHP_VERSION, buf, server_bind_address, document_root);
diff --git a/sapi/cli/php_http_parser.h b/sapi/cli/php_http_parser.h
index b740a0995e..7e72b78d7d 100644
--- a/sapi/cli/php_http_parser.h
+++ b/sapi/cli/php_http_parser.h
@@ -32,7 +32,10 @@ extern "C" {
# include "win32/php_stdint.h"
# include "config.w32.h"
#else
-# include <stdint.h>
+# include "php_config.h"
+# ifdef HAVE_STDINT_H
+# include <stdint.h>
+# endif
#endif
/* Compile with -DPHP_HTTP_PARSER_STRICT=0 to make less checks, but run
diff --git a/sapi/cli/tests/php_cli_server.inc b/sapi/cli/tests/php_cli_server.inc
index 3479cd0bd0..40c5361995 100644
--- a/sapi/cli/tests/php_cli_server.inc
+++ b/sapi/cli/tests/php_cli_server.inc
@@ -38,7 +38,7 @@ function php_cli_server_start($code = 'echo "Hello world";', $no_router = FALSE)
// note: even when server prints 'Listening on localhost:8964...Press Ctrl-C to quit.'
// it might not be listening yet...need to wait until fsockopen() call returns
$i = 0;
- while (($i++ < 5) && !($fp = @fsockopen(PHP_CLI_SERVER_HOSTNAME, PHP_CLI_SERVER_PORT))) {
+ while (($i++ < 30) && !($fp = @fsockopen(PHP_CLI_SERVER_HOSTNAME, PHP_CLI_SERVER_PORT))) {
usleep(10000);
}
diff --git a/sapi/cli/tests/php_cli_server_011.phpt b/sapi/cli/tests/php_cli_server_011.phpt
deleted file mode 100644
index a957a8ed4c..0000000000
--- a/sapi/cli/tests/php_cli_server_011.phpt
+++ /dev/null
@@ -1,41 +0,0 @@
---TEST--
-Bug #60180 ($_SERVER["PHP_SELF"] incorrect)
---SKIPIF--
-<?php
-include "skipif.inc";
-?>
---FILE--
-<?php
-include "php_cli_server.inc";
-php_cli_server_start('sytanx error;', TRUE);
-
-list($host, $port) = explode(':', PHP_CLI_SERVER_ADDRESS);
-$port = intval($port)?:80;
-
-$fp = fsockopen($host, $port, $errno, $errstr, 0.5);
-if (!$fp) {
- die("connect failed");
-}
-
-$logo_id = php_logo_guid();
-
-if(fwrite($fp, <<<HEADER
-GET /?={$logo_id} HTTP/1.1
-Host: {$host}
-
-
-HEADER
-)) {
- while (!feof($fp)) {
- if (("Content-Type: image/gif") == trim(fgets($fp))) {
- echo "okey";
- break;
- }
- }
-}
-
-fclose($fp);
-
-?>
---EXPECTF--
-okey