mirror of
https://github.com/php/php-src.git
synced 2024-11-23 18:04:36 +08:00
Merge branch 'master' into phpng
* master: (41 commits) Update copyright year to 2014 Update copyright year to 2014 Update copyright year to 2014 Update copyright year to 2014 Update copyright year to 2014 Update copyright year to 2014 Update copyright year to 2014 NEWS Fix Request #67453 Allow to unserialize empty data. Update copyright year to 2014 Update copyright year for re2c generated files Update copyright year to 2014 Update copyright year for re2c files as well Fix patch for bug #67436 fix failed test Fix test on modern distro where old unsecure algo are disabled in openssl config. Testing recent algo should be enough to check this function. Added tests for bug 67436 Fixed wrong XFAIL test - already fixed Fix typo in Bug #67406 NEWS entry Fix typo in Bug #67406 NEWS entry ... Conflicts: Zend/zend_compile.c ext/session/session.c ext/standard/array.c ext/standard/http_fopen_wrapper.c tests/classes/bug63462.phpt
This commit is contained in:
commit
b108267f2c
2
LICENSE
2
LICENSE
@ -1,6 +1,6 @@
|
||||
--------------------------------------------------------------------
|
||||
The PHP License, version 3.01
|
||||
Copyright (c) 1999 - 2012 The PHP Group. All rights reserved.
|
||||
Copyright (c) 1999 - 2014 The PHP Group. All rights reserved.
|
||||
--------------------------------------------------------------------
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
|
10
Zend/tests/bug67436/a.php
Normal file
10
Zend/tests/bug67436/a.php
Normal file
@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
class a {
|
||||
public function test($arg = c::TESTCONSTANT) {
|
||||
echo __METHOD__ . "($arg)\n";
|
||||
}
|
||||
|
||||
static public function staticTest() {
|
||||
}
|
||||
}
|
8
Zend/tests/bug67436/b.php
Normal file
8
Zend/tests/bug67436/b.php
Normal file
@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
class b extends a {
|
||||
public function test() {
|
||||
echo __METHOD__ . "()\n";
|
||||
parent::test();
|
||||
}
|
||||
}
|
26
Zend/tests/bug67436/bug67436.phpt
Normal file
26
Zend/tests/bug67436/bug67436.phpt
Normal file
@ -0,0 +1,26 @@
|
||||
--TEST--
|
||||
bug67436: Autoloader isn't called if user defined error handler is present
|
||||
|
||||
--INI--
|
||||
error_reporting=
|
||||
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
spl_autoload_register(function($classname) {
|
||||
if (in_array($classname, array('a','b','c'))) {
|
||||
require_once ($classname . '.php');
|
||||
}
|
||||
});
|
||||
|
||||
set_error_handler(function ($errno, $errstr, $errfile, $errline) {
|
||||
}, error_reporting());
|
||||
|
||||
a::staticTest();
|
||||
|
||||
$b = new b();
|
||||
$b->test();
|
||||
|
||||
--EXPECT--
|
||||
b::test()
|
||||
a::test(c::TESTCONSTANT)
|
24
Zend/tests/bug67436/bug67436_nohandler.phpt
Normal file
24
Zend/tests/bug67436/bug67436_nohandler.phpt
Normal file
@ -0,0 +1,24 @@
|
||||
--TEST--
|
||||
bug67436: E_STRICT instead of custom error handler
|
||||
|
||||
--INI--
|
||||
error_reporting=-1
|
||||
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
spl_autoload_register(function($classname) {
|
||||
if (in_array($classname, array('a','b','c'))) {
|
||||
require_once ($classname . '.php');
|
||||
}
|
||||
});
|
||||
|
||||
a::staticTest();
|
||||
|
||||
$b = new b();
|
||||
$b->test();
|
||||
|
||||
--EXPECTF--
|
||||
Strict Standards: Declaration of b::test() should be compatible with a::test($arg = c::TESTCONSTANT) in %s/bug67436/b.php on line %d
|
||||
b::test()
|
||||
a::test(c::TESTCONSTANT)
|
5
Zend/tests/bug67436/c.php
Normal file
5
Zend/tests/bug67436/c.php
Normal file
@ -0,0 +1,5 @@
|
||||
<?php
|
||||
|
||||
class c {
|
||||
const TESTCONSTANT = "c::TESTCONSTANT";
|
||||
}
|
@ -3461,41 +3461,45 @@ static char * zend_get_function_declaration(zend_function *fptr TSRMLS_DC) /* {{
|
||||
}
|
||||
}
|
||||
if (precv && precv->opcode == ZEND_RECV_INIT && precv->op2_type != IS_UNUSED) {
|
||||
zval zv;
|
||||
zval *zv = precv->op2.zv;
|
||||
|
||||
ZVAL_DUP(&zv, precv->op2.zv);
|
||||
zval_update_constant_ex(&zv, 1, fptr->common.scope TSRMLS_CC);
|
||||
if (Z_TYPE(zv) == IS_FALSE) {
|
||||
if (Z_TYPE_P(zv) == IS_CONSTANT) {
|
||||
REALLOC_BUF_IF_EXCEED(buf, offset, length, Z_STRLEN_P(zv));
|
||||
memcpy(offset, Z_STRVAL_P(zv), Z_STRLEN_P(zv));
|
||||
offset += Z_STRLEN_P(zv);
|
||||
} else if (Z_TYPE_P(zv) == IS_FALSE) {
|
||||
memcpy(offset, "false", 5);
|
||||
offset += 5;
|
||||
} else if (Z_TYPE(zv) == IS_TRUE) {
|
||||
} else if (Z_TYPE_P(zv) == IS_TRUE) {
|
||||
memcpy(offset, "true", 4);
|
||||
offset += 4;
|
||||
} else if (Z_TYPE(zv) == IS_NULL) {
|
||||
} else if (Z_TYPE_P(zv) == IS_NULL) {
|
||||
memcpy(offset, "NULL", 4);
|
||||
offset += 4;
|
||||
} else if (Z_TYPE(zv) == IS_STRING) {
|
||||
} else if (Z_TYPE_P(zv) == IS_STRING) {
|
||||
*(offset++) = '\'';
|
||||
REALLOC_BUF_IF_EXCEED(buf, offset, length, MIN(Z_STRLEN(zv), 10));
|
||||
memcpy(offset, Z_STRVAL(zv), MIN(Z_STRLEN(zv), 10));
|
||||
offset += MIN(Z_STRLEN(zv), 10);
|
||||
if (Z_STRLEN(zv) > 10) {
|
||||
REALLOC_BUF_IF_EXCEED(buf, offset, length, MIN(Z_STRLEN_P(zv), 10));
|
||||
memcpy(offset, Z_STRVAL_P(zv), MIN(Z_STRLEN_P(zv), 10));
|
||||
offset += MIN(Z_STRLEN_P(zv), 10);
|
||||
if (Z_STRLEN_P(zv) > 10) {
|
||||
*(offset++) = '.';
|
||||
*(offset++) = '.';
|
||||
*(offset++) = '.';
|
||||
}
|
||||
*(offset++) = '\'';
|
||||
} else if (Z_TYPE(zv) == IS_ARRAY) {
|
||||
} else if (Z_TYPE_P(zv) == IS_ARRAY) {
|
||||
memcpy(offset, "Array", 5);
|
||||
offset += 5;
|
||||
} else if (Z_TYPE_P(zv) == IS_CONSTANT_AST) {
|
||||
memcpy(offset, "<expression>", 12);
|
||||
offset += 12;
|
||||
} else {
|
||||
zend_string *str = zval_get_string(&zv);
|
||||
zend_string *str = zval_get_string(zv);
|
||||
REALLOC_BUF_IF_EXCEED(buf, offset, length, str->len);
|
||||
memcpy(offset, str->val, str->len);
|
||||
offset += str->len;
|
||||
STR_RELEASE(str);
|
||||
}
|
||||
zval_ptr_dtor(&zv);
|
||||
}
|
||||
} else {
|
||||
memcpy(offset, "NULL", 4);
|
||||
|
@ -4,7 +4,7 @@
|
||||
+----------------------------------------------------------------------+
|
||||
| PHP Version 5 |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 1997-2013 The PHP Group |
|
||||
| Copyright (c) 1997-2014 The PHP Group |
|
||||
+----------------------------------------------------------------------+
|
||||
| This source file is subject to version 3.01 of the PHP license, |
|
||||
| that is bundled with this package in the file LICENSE, and is |
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -46,7 +46,7 @@ array(12) {
|
||||
bool(false)
|
||||
object(DateTime)#1 (3) {
|
||||
["date"]=>
|
||||
string(20) "-0001-11-30 00:00:00.000000"
|
||||
string(27) "-0001-11-30 00:00:00.000000"
|
||||
["timezone_type"]=>
|
||||
int(3)
|
||||
["timezone"]=>
|
||||
|
@ -1,6 +1,6 @@
|
||||
--------------------------------------------------------------------
|
||||
The PHP License, version 3.01
|
||||
Copyright (c) 1999 - 2012 The PHP Group. All rights reserved.
|
||||
Copyright (c) 1999 - 2014 The PHP Group. All rights reserved.
|
||||
--------------------------------------------------------------------
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
|
@ -17,9 +17,7 @@ $ksize = array('1024'=>1024,
|
||||
'4096'=>4096);
|
||||
|
||||
/* array of available hashings to test */
|
||||
$algo = array('md4'=>OPENSSL_ALGO_MD4,
|
||||
'md5'=>OPENSSL_ALGO_MD5,
|
||||
'sha1'=>OPENSSL_ALGO_SHA1,
|
||||
$algo = array('sha1'=>OPENSSL_ALGO_SHA1,
|
||||
'sha224'=>OPENSSL_ALGO_SHA224,
|
||||
'sha256'=>OPENSSL_ALGO_SHA256,
|
||||
'sha384'=>OPENSSL_ALGO_SHA384,
|
||||
@ -90,16 +88,4 @@ bool(false)
|
||||
bool(true)
|
||||
bool(false)
|
||||
bool(true)
|
||||
bool(false)
|
||||
bool(true)
|
||||
bool(false)
|
||||
bool(true)
|
||||
bool(false)
|
||||
bool(true)
|
||||
bool(false)
|
||||
bool(true)
|
||||
bool(false)
|
||||
bool(true)
|
||||
bool(false)
|
||||
bool(true)
|
||||
bool(false)
|
@ -4,7 +4,7 @@
|
||||
+----------------------------------------------------------------------+
|
||||
| PHP Version 5 |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 1997-2013 The PHP Group |
|
||||
| Copyright (c) 1997-2014 The PHP Group |
|
||||
+----------------------------------------------------------------------+
|
||||
| This source file is subject to version 3.01 of the PHP license, |
|
||||
| that is bundled with this package in the file LICENSE, and is |
|
||||
|
@ -2,7 +2,7 @@
|
||||
+----------------------------------------------------------------------+
|
||||
| PHP Version 5 |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 1997-2013 The PHP Group |
|
||||
| Copyright (c) 1997-2014 The PHP Group |
|
||||
+----------------------------------------------------------------------+
|
||||
| This source file is subject to version 3.01 of the PHP license, |
|
||||
| that is bundled with this package in the file LICENSE, and is |
|
||||
|
@ -51,6 +51,7 @@
|
||||
#include "ext/standard/php_smart_str.h"
|
||||
#include "ext/standard/url.h"
|
||||
#include "ext/standard/basic_functions.h"
|
||||
#include "ext/standard/head.h"
|
||||
|
||||
#include "mod_files.h"
|
||||
#include "mod_user.h"
|
||||
@ -1254,14 +1255,6 @@ static int php_session_cache_limiter(TSRMLS_D) /* {{{ */
|
||||
* Cookie Management *
|
||||
********************* */
|
||||
|
||||
#define COOKIE_SET_COOKIE "Set-Cookie: "
|
||||
#define COOKIE_EXPIRES "; expires="
|
||||
#define COOKIE_MAX_AGE "; Max-Age="
|
||||
#define COOKIE_PATH "; path="
|
||||
#define COOKIE_DOMAIN "; domain="
|
||||
#define COOKIE_SECURE "; secure"
|
||||
#define COOKIE_HTTPONLY "; HttpOnly"
|
||||
|
||||
/*
|
||||
* Remove already sent session ID cookie.
|
||||
* It must be directly removed from SG(sapi_header) because sapi_add_header_ex()
|
||||
@ -1327,7 +1320,7 @@ static void php_session_send_cookie(TSRMLS_D) /* {{{ */
|
||||
e_session_name = php_url_encode(PS(session_name), strlen(PS(session_name)));
|
||||
e_id = php_url_encode(PS(id)->val, PS(id)->len);
|
||||
|
||||
smart_str_appends(&ncookie, COOKIE_SET_COOKIE);
|
||||
smart_str_appendl(&ncookie, "Set-Cookie: ", sizeof("Set-Cookie: ")-1);
|
||||
smart_str_appendl(&ncookie, e_session_name->val, e_session_name->len);
|
||||
smart_str_appendc(&ncookie, '=');
|
||||
smart_str_appendl(&ncookie, e_id->val, e_id->len);
|
||||
|
@ -2,7 +2,7 @@
|
||||
+----------------------------------------------------------------------+
|
||||
| PHP Version 5 |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 1997-2012 The PHP Group |
|
||||
| Copyright (c) 1997-2014 The PHP Group |
|
||||
+----------------------------------------------------------------------+
|
||||
| This source file is subject to version 3.01 of the PHP license, |
|
||||
| that is bundled with this package in the file LICENSE, and is |
|
||||
|
@ -2,7 +2,7 @@
|
||||
+----------------------------------------------------------------------+
|
||||
| PHP Version 5 |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 1997-2012 The PHP Group |
|
||||
| Copyright (c) 1997-2014 The PHP Group |
|
||||
+----------------------------------------------------------------------+
|
||||
| This source file is subject to version 3.01 of the PHP license, |
|
||||
| that is bundled with this package in the file LICENSE, and is |
|
||||
|
@ -1781,7 +1781,6 @@ SPL_METHOD(Array, unserialize)
|
||||
}
|
||||
|
||||
if (buf_len == 0) {
|
||||
zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC, "Empty serialized string cannot be empty");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1168,7 +1168,6 @@ SPL_METHOD(SplDoublyLinkedList, unserialize)
|
||||
}
|
||||
|
||||
if (buf_len == 0) {
|
||||
zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC, "Serialized string cannot be empty");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -807,7 +807,6 @@ SPL_METHOD(SplObjectStorage, unserialize)
|
||||
}
|
||||
|
||||
if (buf_len == 0) {
|
||||
zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC, "Empty serialized string cannot be empty");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
--TEST--
|
||||
ArrayObject: test that you cannot unserialize a empty string
|
||||
ArrayObject: test that you can unserialize a empty string
|
||||
--CREDITS--
|
||||
Havard Eide <nucleuz@gmail.com>
|
||||
#PHPTestFest2009 Norway 2009-06-09 \o/
|
||||
@ -8,9 +8,6 @@ Havard Eide <nucleuz@gmail.com>
|
||||
$a = new ArrayObject(array());
|
||||
$a->unserialize("");
|
||||
?>
|
||||
Done
|
||||
--EXPECTF--
|
||||
Fatal error: Uncaught exception 'UnexpectedValueException' with message 'Empty serialized string cannot be empty' in %s.php:%d
|
||||
Stack trace:
|
||||
#0 %s(%d): ArrayObject->unserialize('')
|
||||
#1 {main}
|
||||
thrown in %s.php on line %d
|
||||
Done
|
||||
|
@ -1,5 +1,5 @@
|
||||
--TEST--
|
||||
Check that SplObjectStorage::unserialize throws exception when NULL passed
|
||||
Check that SplObjectStorage::unserialize doesn't throws exception when NULL passed
|
||||
--CREDITS--
|
||||
PHPNW Testfest 2009 - Simon Westcott (swestcott@gmail.com)
|
||||
--FILE--
|
||||
@ -14,6 +14,6 @@ try {
|
||||
}
|
||||
|
||||
?>
|
||||
Done
|
||||
--EXPECTF--
|
||||
Empty serialized string cannot be empty
|
||||
|
||||
Done
|
||||
|
@ -331,7 +331,7 @@ PHP_FUNCTION(count)
|
||||
RETVAL_LONG(zval_get_long(&retval));
|
||||
zval_ptr_dtor(&retval);
|
||||
}
|
||||
zval_dtor(&mode_zv);
|
||||
zval_ptr_dtor(&mode_zv);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
@ -124,7 +124,7 @@ PHPAPI int php_setcookie(char *name, int name_len, char *value, int value_len, t
|
||||
if (expires > 0) {
|
||||
const char *p;
|
||||
char tsdelta[13];
|
||||
strlcat(cookie, "; expires=", len + 100);
|
||||
strlcat(cookie, COOKIE_EXPIRES, len + 100);
|
||||
dt = php_format_date("D, d-M-Y H:i:s T", sizeof("D, d-M-Y H:i:s T")-1, expires, 0 TSRMLS_CC);
|
||||
/* check to make sure that the year does not exceed 4 digits in length */
|
||||
p = zend_memrchr(dt->val, '-', dt->len);
|
||||
@ -139,7 +139,7 @@ PHPAPI int php_setcookie(char *name, int name_len, char *value, int value_len, t
|
||||
STR_FREE(dt);
|
||||
|
||||
snprintf(tsdelta, sizeof(tsdelta), "%li", (long) difftime(expires, time(NULL)));
|
||||
strlcat(cookie, "; Max-Age=", len + 100);
|
||||
strlcat(cookie, COOKIE_MAX_AGE, len + 100);
|
||||
strlcat(cookie, tsdelta, len + 100);
|
||||
}
|
||||
}
|
||||
@ -149,18 +149,18 @@ PHPAPI int php_setcookie(char *name, int name_len, char *value, int value_len, t
|
||||
}
|
||||
|
||||
if (path && path_len > 0) {
|
||||
strlcat(cookie, "; path=", len + 100);
|
||||
strlcat(cookie, COOKIE_PATH, len + 100);
|
||||
strlcat(cookie, path, len + 100);
|
||||
}
|
||||
if (domain && domain_len > 0) {
|
||||
strlcat(cookie, "; domain=", len + 100);
|
||||
strlcat(cookie, COOKIE_DOMAIN, len + 100);
|
||||
strlcat(cookie, domain, len + 100);
|
||||
}
|
||||
if (secure) {
|
||||
strlcat(cookie, "; secure", len + 100);
|
||||
strlcat(cookie, COOKIE_SECURE, len + 100);
|
||||
}
|
||||
if (httponly) {
|
||||
strlcat(cookie, "; httponly", len + 100);
|
||||
strlcat(cookie, COOKIE_HTTPONLY, len + 100);
|
||||
}
|
||||
|
||||
ctr.line = cookie;
|
||||
|
@ -21,6 +21,13 @@
|
||||
#ifndef HEAD_H
|
||||
#define HEAD_H
|
||||
|
||||
#define COOKIE_EXPIRES "; expires="
|
||||
#define COOKIE_MAX_AGE "; Max-Age="
|
||||
#define COOKIE_DOMAIN "; domain="
|
||||
#define COOKIE_PATH "; path="
|
||||
#define COOKIE_SECURE "; secure"
|
||||
#define COOKIE_HTTPONLY "; HttpOnly"
|
||||
|
||||
extern PHP_RINIT_FUNCTION(head);
|
||||
PHP_FUNCTION(header);
|
||||
PHP_FUNCTION(header_remove);
|
||||
|
@ -726,10 +726,11 @@ finish:
|
||||
if (!strncasecmp(http_header_line, "Location: ", 10)) {
|
||||
if (context && (tmpzval = php_stream_context_get_option(context, "http", "follow_location")) != NULL) {
|
||||
follow_location = zval_get_long(tmpzval);
|
||||
} else if (!((response_code >= 300 && response_code < 304) || 307 == response_code)) {
|
||||
} else if (!(response_code >= 300 && response_code < 304 || 307 == response_code || 308 == 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 */
|
||||
see http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.3.1
|
||||
RFC 7238 defines 308: http://tools.ietf.org/html/rfc7238 */
|
||||
follow_location = 0;
|
||||
}
|
||||
strlcpy(location, http_header_line + 10, sizeof(location));
|
||||
|
@ -0,0 +1,11 @@
|
||||
--TEST--
|
||||
Location: headers change the status code
|
||||
--CGI--
|
||||
--FILE--
|
||||
<?php
|
||||
header('Location: http://example.com/');
|
||||
?>
|
||||
--EXPECTHEADERS--
|
||||
Status: 302 Moved Temporarily
|
||||
Location: http://example.com/
|
||||
--EXPECT--
|
@ -0,0 +1,12 @@
|
||||
--TEST--
|
||||
Location: headers override non-201 and 3xx response codes
|
||||
--CGI--
|
||||
--FILE--
|
||||
<?php
|
||||
header("HTTP/1.1 418 I'm a Teapot");
|
||||
header('Location: http://example.com/');
|
||||
?>
|
||||
--EXPECTHEADERS--
|
||||
Status: 302 Moved Temporarily
|
||||
Location: http://example.com/
|
||||
--EXPECT--
|
@ -0,0 +1,11 @@
|
||||
--TEST--
|
||||
Location: headers respect the header() response code parameter
|
||||
--CGI--
|
||||
--FILE--
|
||||
<?php
|
||||
header('Location: http://example.com/', true, 404);
|
||||
?>
|
||||
--EXPECTHEADERS--
|
||||
Status: 404 Not Found
|
||||
Location: http://example.com/
|
||||
--EXPECT--
|
@ -0,0 +1,11 @@
|
||||
--TEST--
|
||||
Location: headers respect the header() response code parameter
|
||||
--CGI--
|
||||
--FILE--
|
||||
<?php
|
||||
header('Location: http://example.com/', true, 404);
|
||||
?>
|
||||
--EXPECTHEADERS--
|
||||
Status: 404 Not Found
|
||||
Location: http://example.com/
|
||||
--EXPECT--
|
@ -0,0 +1,12 @@
|
||||
--TEST--
|
||||
Location: headers do not override the 201 response code
|
||||
--CGI--
|
||||
--FILE--
|
||||
<?php
|
||||
header('HTTP/1.1 201 Created');
|
||||
header('Location: http://example.com/');
|
||||
?>
|
||||
--EXPECTHEADERS--
|
||||
Status: 201 Created
|
||||
Location: http://example.com/
|
||||
--EXPECT--
|
@ -0,0 +1,12 @@
|
||||
--TEST--
|
||||
Location: headers do not override the 300 Multiple Choices response code
|
||||
--CGI--
|
||||
--FILE--
|
||||
<?php
|
||||
header('HTTP/1.1 300 Multiple Choices');
|
||||
header('Location: http://example.com/');
|
||||
?>
|
||||
--EXPECTHEADERS--
|
||||
Status: 300 Multiple Choices
|
||||
Location: http://example.com/
|
||||
--EXPECT--
|
@ -0,0 +1,12 @@
|
||||
--TEST--
|
||||
Location: headers do not override the 301 Moved Permanently response code
|
||||
--CGI--
|
||||
--FILE--
|
||||
<?php
|
||||
header('HTTP/1.1 301 Moved Permanently');
|
||||
header('Location: http://example.com/');
|
||||
?>
|
||||
--EXPECTHEADERS--
|
||||
Status: 301 Moved Permanently
|
||||
Location: http://example.com/
|
||||
--EXPECT--
|
@ -0,0 +1,12 @@
|
||||
--TEST--
|
||||
Location: headers do not override the 302 Found response code
|
||||
--CGI--
|
||||
--FILE--
|
||||
<?php
|
||||
header('HTTP/1.1 302 Found');
|
||||
header('Location: http://example.com/');
|
||||
?>
|
||||
--EXPECTHEADERS--
|
||||
Status: 302 Found
|
||||
Location: http://example.com/
|
||||
--EXPECT--
|
@ -0,0 +1,12 @@
|
||||
--TEST--
|
||||
Location: headers do not override the 303 See Other response code
|
||||
--CGI--
|
||||
--FILE--
|
||||
<?php
|
||||
header('HTTP/1.1 303 See Other');
|
||||
header('Location: http://example.com/');
|
||||
?>
|
||||
--EXPECTHEADERS--
|
||||
Status: 303 See Other
|
||||
Location: http://example.com/
|
||||
--EXPECT--
|
@ -0,0 +1,12 @@
|
||||
--TEST--
|
||||
Location: headers do not override the 304 Not Modified response code
|
||||
--CGI--
|
||||
--FILE--
|
||||
<?php
|
||||
header('HTTP/1.1 304 Not Modified');
|
||||
header('Location: http://example.com/');
|
||||
?>
|
||||
--EXPECTHEADERS--
|
||||
Status: 304 Not Modified
|
||||
Location: http://example.com/
|
||||
--EXPECT--
|
@ -0,0 +1,12 @@
|
||||
--TEST--
|
||||
Location: headers do not override the 305 Use Proxy response code
|
||||
--CGI--
|
||||
--FILE--
|
||||
<?php
|
||||
header('HTTP/1.1 305 Use Proxy');
|
||||
header('Location: http://example.com/');
|
||||
?>
|
||||
--EXPECTHEADERS--
|
||||
Status: 305 Use Proxy
|
||||
Location: http://example.com/
|
||||
--EXPECT--
|
@ -0,0 +1,12 @@
|
||||
--TEST--
|
||||
Location: headers do not override the 307 Temporary Redirect response code
|
||||
--CGI--
|
||||
--FILE--
|
||||
<?php
|
||||
header('HTTP/1.1 307 Temporary Redirect');
|
||||
header('Location: http://example.com/');
|
||||
?>
|
||||
--EXPECTHEADERS--
|
||||
Status: 307 Temporary Redirect
|
||||
Location: http://example.com/
|
||||
--EXPECT--
|
@ -0,0 +1,12 @@
|
||||
--TEST--
|
||||
Location: headers do not override the 308 Permanent Redirect response code
|
||||
--CGI--
|
||||
--FILE--
|
||||
<?php
|
||||
header('HTTP/1.1 308 Permanent Redirect');
|
||||
header('Location: http://example.com/');
|
||||
?>
|
||||
--EXPECTHEADERS--
|
||||
Status: 308 Permanent Redirect
|
||||
Location: http://example.com/
|
||||
--EXPECT--
|
@ -0,0 +1,12 @@
|
||||
--TEST--
|
||||
Location: headers do not override the 399 Choose Your Own Adventure response code
|
||||
--CGI--
|
||||
--FILE--
|
||||
<?php
|
||||
header('HTTP/1.1 399 Choose Your Own Adventure');
|
||||
header('Location: http://example.com/');
|
||||
?>
|
||||
--EXPECTHEADERS--
|
||||
Status: 399 Choose Your Own Adventure
|
||||
Location: http://example.com/
|
||||
--EXPECT--
|
49
ext/standard/tests/http/bug67430.phpt
Normal file
49
ext/standard/tests/http/bug67430.phpt
Normal file
@ -0,0 +1,49 @@
|
||||
--TEST--
|
||||
Bug #67430 (http:// wrapper doesn't follow 308 redirects)
|
||||
--INI--
|
||||
allow_url_fopen=1
|
||||
--SKIPIF--
|
||||
<?php require 'server.inc'; http_server_skipif('tcp://127.0.0.1:12342'); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
require 'server.inc';
|
||||
|
||||
function do_test($follow) {
|
||||
$options = [
|
||||
'http' => [
|
||||
'method' => 'POST',
|
||||
'follow_location' => $follow,
|
||||
],
|
||||
];
|
||||
|
||||
$ctx = stream_context_create($options);
|
||||
|
||||
$responses = [
|
||||
"data://text/plain,HTTP/1.1 308\r\nLocation: /foo\r\n\r\n",
|
||||
"data://text/plain,HTTP/1.1 200\r\nConnection: close\r\n\r\n",
|
||||
];
|
||||
$pid = http_server('tcp://127.0.0.1:12342', $responses, $output);
|
||||
|
||||
$fd = fopen('http://127.0.0.1:12342/', 'rb', false, $ctx);
|
||||
fseek($output, 0, SEEK_SET);
|
||||
echo stream_get_contents($output);
|
||||
|
||||
http_server_kill($pid);
|
||||
}
|
||||
|
||||
do_test(true);
|
||||
do_test(false);
|
||||
|
||||
?>
|
||||
Done
|
||||
--EXPECT--
|
||||
POST / HTTP/1.0
|
||||
Host: 127.0.0.1:12342
|
||||
|
||||
GET /foo HTTP/1.0
|
||||
Host: 127.0.0.1:12342
|
||||
|
||||
POST / HTTP/1.0
|
||||
Host: 127.0.0.1:12342
|
||||
|
||||
Done
|
@ -29,7 +29,7 @@ $expected = array(
|
||||
'Set-Cookie: name=value; path=/path/',
|
||||
'Set-Cookie: name=value; domain=domain.tld',
|
||||
'Set-Cookie: name=value; secure',
|
||||
'Set-Cookie: name=value; httponly'
|
||||
'Set-Cookie: name=value; HttpOnly'
|
||||
);
|
||||
|
||||
$headers = headers_list();
|
||||
|
@ -4,7 +4,7 @@
|
||||
+----------------------------------------------------------------------+
|
||||
| PHP Version 5 |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 1997-2013 The PHP Group |
|
||||
| Copyright (c) 1997-2014 The PHP Group |
|
||||
+----------------------------------------------------------------------+
|
||||
| This source file is subject to version 3.01 of the PHP license, |
|
||||
| that is bundled with this package in the file LICENSE, and is |
|
||||
|
@ -2,7 +2,7 @@
|
||||
+----------------------------------------------------------------------+
|
||||
| PHP Version 5 |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 1997-2013 The PHP Group |
|
||||
| Copyright (c) 1997-2014 The PHP Group |
|
||||
+----------------------------------------------------------------------+
|
||||
| This source file is subject to version 3.01 of the PHP license, |
|
||||
| that is bundled with this package in the file LICENSE, and is |
|
||||
|
@ -4,7 +4,7 @@
|
||||
+----------------------------------------------------------------------+
|
||||
| PHP Version 5 |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 1997-2013 The PHP Group |
|
||||
| Copyright (c) 1997-2014 The PHP Group |
|
||||
+----------------------------------------------------------------------+
|
||||
| This source file is subject to version 3.01 of the PHP license, |
|
||||
| that is bundled with this package in the file LICENSE, and is |
|
||||
|
@ -2,7 +2,7 @@
|
||||
+----------------------------------------------------------------------+
|
||||
| PHP Version 5 |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 1997-2013 The PHP Group |
|
||||
| Copyright (c) 1997-2014 The PHP Group |
|
||||
+----------------------------------------------------------------------+
|
||||
| This source file is subject to version 3.01 of the PHP license, |
|
||||
| that is bundled with this package in the file LICENSE, and is |
|
||||
|
2
header
2
header
@ -2,7 +2,7 @@
|
||||
+----------------------------------------------------------------------+
|
||||
| PHP Version 5 |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 1997-2013 The PHP Group |
|
||||
| Copyright (c) 1997-2014 The PHP Group |
|
||||
+----------------------------------------------------------------------+
|
||||
| This source file is subject to version 3.01 of the PHP license, |
|
||||
| that is bundled with this package in the file LICENSE, and is |
|
||||
|
@ -823,7 +823,7 @@ SAPI_API int sapi_header_op(sapi_header_op_enum op, void *arg TSRMLS_DC)
|
||||
STR_RELEASE(key);
|
||||
} else if (!STRCASECMP(header_line, "Location")) {
|
||||
if ((SG(sapi_headers).http_response_code < 300 ||
|
||||
SG(sapi_headers).http_response_code > 307) &&
|
||||
SG(sapi_headers).http_response_code > 399) &&
|
||||
SG(sapi_headers).http_response_code != 201) {
|
||||
/* Return a Found Redirect if one is not already specified */
|
||||
if (http_response_code) { /* user specified redirect code */
|
||||
|
@ -1,4 +1,4 @@
|
||||
.TH PHP 1 "2013" "The PHP Group" "Scripting Language"
|
||||
.TH PHP 1 "2014" "The PHP Group" "Scripting Language"
|
||||
.SH NAME
|
||||
php \- PHP Command Line Interface 'CLI'
|
||||
.P
|
||||
@ -454,7 +454,7 @@ contributors all around the world.
|
||||
.SH VERSION INFORMATION
|
||||
This manpage describes \fBphp\fP, version @PHP_VERSION@.
|
||||
.SH COPYRIGHT
|
||||
Copyright \(co 1997\-2013 The PHP Group
|
||||
Copyright \(co 1997\-2014 The PHP Group
|
||||
.LP
|
||||
This source file is subject to version 3.01 of the PHP license,
|
||||
that is bundled with this package in the file LICENSE, and is
|
||||
|
@ -220,6 +220,7 @@ static php_cli_server_http_response_status_code_pair status_map[] = {
|
||||
{ 304, "Not Modified" },
|
||||
{ 305, "Use Proxy" },
|
||||
{ 307, "Temporary Redirect" },
|
||||
{ 308, "Permanent Redirect" },
|
||||
{ 400, "Bad Request" },
|
||||
{ 401, "Unauthorized" },
|
||||
{ 402, "Payment Required" },
|
||||
@ -238,6 +239,7 @@ static php_cli_server_http_response_status_code_pair status_map[] = {
|
||||
{ 415, "Unsupported Media Type" },
|
||||
{ 416, "Requested Range Not Satisfiable" },
|
||||
{ 417, "Expectation Failed" },
|
||||
{ 426, "Upgrade Required" },
|
||||
{ 428, "Precondition Required" },
|
||||
{ 429, "Too Many Requests" },
|
||||
{ 431, "Request Header Fields Too Large" },
|
||||
|
49
sapi/cli/tests/bug67429.phpt
Normal file
49
sapi/cli/tests/bug67429.phpt
Normal file
@ -0,0 +1,49 @@
|
||||
--TEST--
|
||||
FR #67429 (CLI server is missing some new HTTP response codes)
|
||||
--SKIPIF--
|
||||
<?php
|
||||
include "skipif.inc";
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
include "php_cli_server.inc";
|
||||
|
||||
foreach ([308, 426] as $code) {
|
||||
php_cli_server_start(<<<PHP
|
||||
http_response_code($code);
|
||||
PHP
|
||||
);
|
||||
|
||||
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");
|
||||
}
|
||||
|
||||
if(fwrite($fp, <<<HEADER
|
||||
GET / HTTP/1.1
|
||||
|
||||
|
||||
HEADER
|
||||
)) {
|
||||
while (!feof($fp)) {
|
||||
echo fgets($fp);
|
||||
}
|
||||
}
|
||||
|
||||
fclose($fp);
|
||||
}
|
||||
?>
|
||||
--EXPECTF--
|
||||
HTTP/1.1 308 Permanent Redirect
|
||||
Connection: close
|
||||
X-Powered-By: %s
|
||||
Content-type: text/html; charset=UTF-8
|
||||
|
||||
HTTP/1.1 426 Upgrade Required
|
||||
Connection: close
|
||||
X-Powered-By: %s
|
||||
Content-type: text/html; charset=UTF-8
|
||||
|
@ -462,7 +462,7 @@ int phpFinit(lstTset * opt)
|
||||
core_globals = ts_resource(core_globals_id);
|
||||
|
||||
logFmsg(0, "mod/php: PHP Interface v3 (module)");
|
||||
logFmsg(0, "mod/php: Copyright (c) 1999-2013 The PHP Group. All rights reserved.");
|
||||
logFmsg(0, "mod/php: Copyright (c) 1999-2014 The PHP Group. All rights reserved.");
|
||||
|
||||
sapi_startup(&capi_sapi_module);
|
||||
capi_sapi_module.startup(&capi_sapi_module);
|
||||
|
@ -1,3 +1,12 @@
|
||||
language: c
|
||||
|
||||
script: ./travis/ci.sh
|
||||
env:
|
||||
- PHP="PHP-5.4"
|
||||
- PHP="PHP-5.5"
|
||||
- PHP="PHP-5.6"
|
||||
- PHP="master"
|
||||
|
||||
before_script: ./travis/ci.sh
|
||||
|
||||
script:
|
||||
- ./php-src/sapi/cli/php php-src/sapi/phpdbg/tests/run-tests.php -diff2stdout --phpdbg php-src/sapi/phpdbg/phpdbg
|
||||
|
@ -9,6 +9,7 @@ PHP_ARG_ENABLE(phpdbg-debug, for phpdbg debug build,
|
||||
[ --enable-phpdbg-debug Build phpdbg in debug mode], no, no)
|
||||
|
||||
if test "$PHP_PHPDBG" != "no"; then
|
||||
AC_HEADER_TIOCGWINSZ
|
||||
AC_DEFINE(HAVE_PHPDBG, 1, [ ])
|
||||
|
||||
if test "$PHP_PHPDBG_DEBUG" != "no"; then
|
||||
|
@ -2,7 +2,7 @@
|
||||
+----------------------------------------------------------------------+
|
||||
| PHP Version 5 |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 1997-2013 The PHP Group |
|
||||
| Copyright (c) 1997-2014 The PHP Group |
|
||||
+----------------------------------------------------------------------+
|
||||
| This source file is subject to version 3.01 of the PHP license, |
|
||||
| that is bundled with this package in the file LICENSE, and is |
|
||||
|
@ -2,7 +2,7 @@
|
||||
+----------------------------------------------------------------------+
|
||||
| PHP Version 5 |
|
||||
+----------------------------------------------------------------------+
|
||||
| Copyright (c) 1997-2013 The PHP Group |
|
||||
| Copyright (c) 1997-2014 The PHP Group |
|
||||
+----------------------------------------------------------------------+
|
||||
| This source file is subject to version 3.01 of the PHP license, |
|
||||
| that is bundled with this package in the file LICENSE, and is |
|
||||
|
@ -32,6 +32,9 @@
|
||||
# include "win32/time.h"
|
||||
#elif defined(HAVE_SYS_IOCTL_H)
|
||||
# include "sys/ioctl.h"
|
||||
# ifndef GWINSZ_IN_SYS_IOCTL
|
||||
# include <termios.h>
|
||||
# endif
|
||||
#endif
|
||||
|
||||
ZEND_EXTERN_MODULE_GLOBALS(phpdbg);
|
||||
@ -437,12 +440,12 @@ PHPDBG_API int phpdbg_get_terminal_width(TSRMLS_D) /* {{{ */
|
||||
|
||||
GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi);
|
||||
columns = csbi.srWindow.Right - csbi.srWindow.Left + 1;
|
||||
#elif defined(HAVE_SYS_IOCTL_H)
|
||||
#elif defined(HAVE_SYS_IOCTL_H) && defined (TIOCGWINSZ)
|
||||
struct winsize w;
|
||||
|
||||
columns = ioctl(fileno(stdout), TIOCGWINSZ, &w) == 0 ? w.ws_col : 100;
|
||||
columns = ioctl(fileno(stdout), TIOCGWINSZ, &w) == 0 ? w.ws_col : 80;
|
||||
#else
|
||||
columns = 100;
|
||||
columns = 80;
|
||||
#endif
|
||||
return columns;
|
||||
} /* }}} */
|
||||
|
@ -124,4 +124,24 @@ PHPDBG_API int phpdbg_get_terminal_width(TSRMLS_D); /* }}} */
|
||||
|
||||
int phpdbg_rebuild_symtable(TSRMLS_D);
|
||||
|
||||
#if PHP_VERSION_ID < 50500
|
||||
/* copy from zend_hash.c PHP 5.5 for 5.4 compatibility */
|
||||
static void zend_hash_get_current_key_zval_ex(const HashTable *ht, zval *key, HashPosition *pos) {
|
||||
Bucket *p;
|
||||
|
||||
p = pos ? (*pos) : ht->pInternalPointer;
|
||||
|
||||
if (!p) {
|
||||
Z_TYPE_P(key) = IS_NULL;
|
||||
} else if (p->nKeyLength) {
|
||||
Z_TYPE_P(key) = IS_STRING;
|
||||
Z_STRVAL_P(key) = IS_INTERNED(p->arKey) ? (char*)p->arKey : estrndup(p->arKey, p->nKeyLength - 1);
|
||||
Z_STRLEN_P(key) = p->nKeyLength - 1;
|
||||
} else {
|
||||
Z_TYPE_P(key) = IS_LONG;
|
||||
Z_LVAL_P(key) = p->h;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* PHPDBG_UTILS_H */
|
||||
|
@ -135,8 +135,8 @@ namespace phpdbg\testing {
|
||||
* @param array basic configuration
|
||||
* @param array command line
|
||||
*/
|
||||
public function __construct(TestsConfiguration &$config) {
|
||||
$this->config = &$config;
|
||||
public function __construct(TestsConfiguration $config) {
|
||||
$this->config = $config;
|
||||
|
||||
if ($this->config->hasFlag('help') ||
|
||||
$this->config->hasFlag('h')) {
|
||||
@ -153,7 +153,7 @@ namespace phpdbg\testing {
|
||||
$paths = array();
|
||||
$where = ($in != null) ? array($in) : $this->config['path'];
|
||||
|
||||
foreach ($where as &$path) {
|
||||
foreach ($where as $path) {
|
||||
if ($path) {
|
||||
if (is_dir($path)) {
|
||||
$paths[] = $path;
|
||||
@ -243,6 +243,7 @@ namespace phpdbg\testing {
|
||||
printf("\t--options\toptions to pass to phpdbg%s", PHP_EOL);
|
||||
printf("\t--phpdbg\tpath to phpdbg binary%s", PHP_EOL);
|
||||
printf('[flags]:%s', PHP_EOL);
|
||||
printf("\t-diff2stdout\t\twrite diff to stdout instead of files%s", PHP_EOL);
|
||||
printf("\t-nodiff\t\tdo not write diffs on failure%s", PHP_EOL);
|
||||
printf("\t-nolog\t\tdo not write logs on failure%s", PHP_EOL);
|
||||
printf('[examples]:%s', PHP_EOL);
|
||||
@ -266,9 +267,11 @@ namespace phpdbg\testing {
|
||||
$test = sprintf('%s/%s', $path, $file);
|
||||
|
||||
if (preg_match('~\.test$~', $test)) {
|
||||
yield new Test($this->config, $test);
|
||||
$tests[] = new Test($this->config, $test);
|
||||
}
|
||||
}
|
||||
|
||||
return $tests;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -354,7 +357,7 @@ namespace phpdbg\testing {
|
||||
* @param array configuration
|
||||
* @param string file
|
||||
*/
|
||||
public function __construct(TestsConfiguration &$config, &$file) {
|
||||
public function __construct(TestsConfiguration $config, $file) {
|
||||
if (($handle = fopen($file, 'r'))) {
|
||||
while (($line = fgets($handle))) {
|
||||
$trim = trim($line);
|
||||
@ -417,8 +420,8 @@ namespace phpdbg\testing {
|
||||
}
|
||||
fclose($handle);
|
||||
|
||||
$this->config = &$config;
|
||||
$this->file = &$file;
|
||||
$this->config = $config;
|
||||
$this->file = $file;
|
||||
}
|
||||
}
|
||||
|
||||
@ -427,8 +430,7 @@ namespace phpdbg\testing {
|
||||
*
|
||||
*/
|
||||
public function getResult() {
|
||||
$options = sprintf(
|
||||
'-i%s -nqb', $this->file);
|
||||
$options = sprintf('-i%s -nqb', $this->file);
|
||||
|
||||
if ($this->options) {
|
||||
$options = sprintf(
|
||||
@ -526,7 +528,7 @@ namespace phpdbg\testing {
|
||||
* Write log to disk if configuration allows it
|
||||
*
|
||||
*/
|
||||
protected function writeLog(&$result = null) {
|
||||
protected function writeLog($result = null) {
|
||||
$log = sprintf(
|
||||
'%s/%s.log',
|
||||
dirname($this->file), basename($this->file));
|
||||
|
@ -1,10 +1,11 @@
|
||||
#!/usr/bin/env sh
|
||||
git clone https://github.com/php/php-src
|
||||
cd php-src/sapi
|
||||
cd php-src
|
||||
git checkout $PHP
|
||||
cd sapi
|
||||
rm -rf phpdbg
|
||||
git clone https://github.com/krakjoe/phpdbg.git
|
||||
cd ../
|
||||
./buildconf --force
|
||||
./configure --disable-all --enable-phpdbg --enable-maintainer-zts
|
||||
make
|
||||
make test-phpdbg
|
||||
|
@ -18,7 +18,7 @@ class Test {
|
||||
}
|
||||
|
||||
function __get($name) {
|
||||
echo '__get ' . $name . "\n";
|
||||
echo '__get ' . $name;
|
||||
return $this->$name;
|
||||
}
|
||||
|
||||
@ -52,16 +52,12 @@ $test->privateProperty = 'value';
|
||||
|
||||
--EXPECTF--
|
||||
__get nonExisting
|
||||
|
||||
Notice: Undefined property: Test::$nonExisting in %sbug63462.php on line %d
|
||||
__get publicProperty
|
||||
|
||||
Notice: Undefined property: Test::$publicProperty in %sbug63462.php on line %d
|
||||
__get protectedProperty
|
||||
|
||||
Notice: Undefined property: Test::$protectedProperty in %sbug63462.php on line %d
|
||||
__get privateProperty
|
||||
|
||||
Notice: Undefined property: Test::$privateProperty in %sbug63462.php on line %d
|
||||
__isset nonExisting
|
||||
__isset publicProperty
|
||||
|
@ -65,7 +65,7 @@ BEGIN
|
||||
#endif
|
||||
VALUE "FileVersion", EXT_VERSION
|
||||
VALUE "InternalName", INTERNAL_NAME
|
||||
VALUE "LegalCopyright", "Copyright © 1997-2013 The PHP Group"
|
||||
VALUE "LegalCopyright", "Copyright © 1997-2014 The PHP Group"
|
||||
VALUE "LegalTrademarks", "PHP"
|
||||
VALUE "OriginalFilename", FILE_NAME
|
||||
VALUE "ProductName", "PHP"
|
||||
|
Loading…
Reference in New Issue
Block a user