summaryrefslogtreecommitdiff
path: root/ext/standard
diff options
context:
space:
mode:
Diffstat (limited to 'ext/standard')
-rw-r--r--ext/standard/credits_sapi.h2
-rw-r--r--ext/standard/dns.c2
-rw-r--r--ext/standard/head.c2
-rw-r--r--ext/standard/http_fopen_wrapper.c9
-rw-r--r--ext/standard/streamsfuncs.c2
-rw-r--r--ext/standard/tests/file/bug44805.phpt2
-rw-r--r--ext/standard/tests/streams/bug64433.phpt86
-rw-r--r--ext/standard/tests/streams/bug64433_srv.inc14
8 files changed, 111 insertions, 8 deletions
diff --git a/ext/standard/credits_sapi.h b/ext/standard/credits_sapi.h
index 9cc7e6e22..d147d8dea 100644
--- a/ext/standard/credits_sapi.h
+++ b/ext/standard/credits_sapi.h
@@ -17,7 +17,7 @@ CREDIT_LINE("Apache 2.0 Filter", "Sascha Schumann, Aaron Bannert");
CREDIT_LINE("Apache 2.0 Handler", "Ian Holsman, Justin Erenkrantz (based on Apache 2.0 Filter code)");
CREDIT_LINE("Caudium / Roxen", "David Hedbor");
CREDIT_LINE("CGI / FastCGI", "Rasmus Lerdorf, Stig Bakken, Shane Caraveo, Dmitry Stogov");
-CREDIT_LINE("CLI", "Edin Kadribasic, Marcus Boerger, Johannes Schlueter");
+CREDIT_LINE("CLI", "Edin Kadribasic, Marcus Boerger, Johannes Schlueter, Moriyoshi Koizumi, Xinchen Hui");
CREDIT_LINE("Continuity", "Alex Leigh (based on nsapi code)");
CREDIT_LINE("Embed", "Edin Kadribasic");
CREDIT_LINE("FastCGI Process Manager", "Andrei Nigmatulin, dreamcat4, Antony Dovgal, Jerome Loyet");
diff --git a/ext/standard/dns.c b/ext/standard/dns.c
index 074c16ee9..3584fc1bf 100644
--- a/ext/standard/dns.c
+++ b/ext/standard/dns.c
@@ -524,7 +524,7 @@ static u_char *php_parserr(u_char *cp, querybuf *answer, int type_to_fetch, int
tp[dlen] = '\0';
cp += dlen;
- add_assoc_stringl(*subarray, "txt", tp, dlen - 1, 0);
+ add_assoc_stringl(*subarray, "txt", tp, (dlen>0)?dlen - 1:0, 0);
add_assoc_zval(*subarray, "entries", entries);
}
break;
diff --git a/ext/standard/head.c b/ext/standard/head.c
index 97f61f2be..da08c36cf 100644
--- a/ext/standard/head.c
+++ b/ext/standard/head.c
@@ -131,7 +131,7 @@ PHPAPI int php_setcookie(char *name, int name_len, char *value, int value_len, t
efree(dt);
efree(cookie);
efree(encoded_value);
- zend_error(E_WARNING, "Expiry date cannot have a year greater then 9999");
+ zend_error(E_WARNING, "Expiry date cannot have a year greater than 9999");
return FAILURE;
}
strlcat(cookie, dt, len + 100);
diff --git a/ext/standard/http_fopen_wrapper.c b/ext/standard/http_fopen_wrapper.c
index 870f904e9..b8676bbba 100644
--- a/ext/standard/http_fopen_wrapper.c
+++ b/ext/standard/http_fopen_wrapper.c
@@ -731,12 +731,15 @@ finish:
http_header_line[http_header_line_length] = '\0';
if (!strncasecmp(http_header_line, "Location: ", 10)) {
- /* we only care about Location for 300, 301, 302, 303 and 307 */
- /* see http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.3.1 */
- if ((response_code >= 300 && response_code < 304 || 307 == response_code) && context && php_stream_context_get_option(context, "http", "follow_location", &tmpzval) == SUCCESS) {
+ if (context && php_stream_context_get_option(context, "http", "follow_location", &tmpzval) == SUCCESS) {
SEPARATE_ZVAL(tmpzval);
convert_to_long_ex(tmpzval);
follow_location = Z_LVAL_PP(tmpzval);
+ } else if (!(response_code >= 300 && response_code < 304 || 307 == response_code)) {
+ /* we shouldn't redirect automatically
+ if follow_location isn't set and response_code not in (300, 301, 302, 303 and 307)
+ see http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.3.1 */
+ follow_location = 0;
}
strlcpy(location, http_header_line + 10, sizeof(location));
} else if (!strncasecmp(http_header_line, "Content-Type: ", 14)) {
diff --git a/ext/standard/streamsfuncs.c b/ext/standard/streamsfuncs.c
index 2231a3098..21c55e404 100644
--- a/ext/standard/streamsfuncs.c
+++ b/ext/standard/streamsfuncs.c
@@ -51,7 +51,7 @@ PHP_FUNCTION(stream_socket_pair)
{
long domain, type, protocol;
php_stream *s1, *s2;
- int pair[2];
+ php_socket_t pair[2];
if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lll",
&domain, &type, &protocol)) {
diff --git a/ext/standard/tests/file/bug44805.phpt b/ext/standard/tests/file/bug44805.phpt
index 85f1255a6..8e13c3862 100644
--- a/ext/standard/tests/file/bug44805.phpt
+++ b/ext/standard/tests/file/bug44805.phpt
@@ -22,7 +22,7 @@ readfile($file2);
if (file_exists($file1)) {
unlink($file1);
}
-if (file_exists($file1)) {
+if (file_exists($file2)) {
unlink($file2);
}
?>
diff --git a/ext/standard/tests/streams/bug64433.phpt b/ext/standard/tests/streams/bug64433.phpt
new file mode 100644
index 000000000..f973768f8
--- /dev/null
+++ b/ext/standard/tests/streams/bug64433.phpt
@@ -0,0 +1,86 @@
+--TEST--
+Bug #60180 ($_SERVER["PHP_SELF"] incorrect)
+--SKIPIF--
+<?php
+if(!file_exists(dirname(__FILE__)."/../../../../sapi/cli/tests/php_cli_server.inc"))
+ die("skip could not found cli server script");
+$res = @include dirname(__FILE__)."/../../../../sapi/cli/tests/php_cli_server.inc";
+if(!$res) {
+ die("skip could not open cli server script");
+}
+
+if (CURL_WRAPPERS_ENABLED) {
+ die("skip curl wrappers used");
+}
+?>
+--FILE--
+<?php
+include dirname(__FILE__)."/../../../../sapi/cli/tests/php_cli_server.inc";
+php_cli_server_start(file_get_contents(dirname(__FILE__).'/bug64433_srv.inc'));
+
+echo file_get_contents("http://".PHP_CLI_SERVER_ADDRESS."/index.php");
+echo "default\n";
+$codes = array(200, 201, 204, 301, 302, 303, 304, 305, 307, 404, 500);
+foreach($codes as $code) {
+ echo "$code: ".file_get_contents("http://".PHP_CLI_SERVER_ADDRESS."/index.php?status=$code&loc=1");
+}
+echo "follow=0\n";
+$arr = array('http'=>
+ array(
+ 'follow_location'=>0,
+ )
+ );
+$context = stream_context_create($arr);
+foreach($codes as $code) {
+ echo "$code: ".file_get_contents("http://".PHP_CLI_SERVER_ADDRESS."/index.php?status=$code&loc=1", false, $context);
+}
+echo "follow=1\n";
+$arr = array('http'=>
+ array(
+ 'follow_location'=>1,
+ )
+ );
+$context = stream_context_create($arr);
+foreach($codes as $code) {
+ echo "$code: ".file_get_contents("http://".PHP_CLI_SERVER_ADDRESS."/index.php?status=$code&loc=1", false, $context);
+}
+--EXPECT--
+HELLO!
+default
+200: HELLO!
+201: HELLO!
+204: HELLO!
+301: REDIRECTED
+302: REDIRECTED
+303: REDIRECTED
+304: HELLO!
+305: HELLO!
+307: REDIRECTED
+404: HELLO!
+500: HELLO!
+follow=0
+200: HELLO!
+201: HELLO!
+204: HELLO!
+301: HELLO!
+302: HELLO!
+303: HELLO!
+304: HELLO!
+305: HELLO!
+307: HELLO!
+404: HELLO!
+500: HELLO!
+follow=1
+200: REDIRECTED
+201: REDIRECTED
+204: REDIRECTED
+301: REDIRECTED
+302: REDIRECTED
+303: REDIRECTED
+304: REDIRECTED
+305: REDIRECTED
+307: REDIRECTED
+404: REDIRECTED
+500: REDIRECTED
+
+
diff --git a/ext/standard/tests/streams/bug64433_srv.inc b/ext/standard/tests/streams/bug64433_srv.inc
new file mode 100644
index 000000000..e79a2fd6d
--- /dev/null
+++ b/ext/standard/tests/streams/bug64433_srv.inc
@@ -0,0 +1,14 @@
+if(!empty($_REQUEST["redir"])) {
+ echo "REDIRECTED\n";
+ return;
+}
+
+if(!empty($_REQUEST["loc"])) {
+ header("Location: index.php?redir=1");
+}
+
+if(!empty($_REQUEST["status"])) {
+ http_response_code($_REQUEST["status"]);
+}
+
+echo "HELLO!\n"; \ No newline at end of file