mirror of
https://github.com/php/php-src.git
synced 2026-04-29 11:13:36 +02:00
Merge branch 'PHP-7.1'
* PHP-7.1: Fix bug #72940 properly. Reduce needless branches
This commit is contained in:
+38
-41
@@ -1483,50 +1483,47 @@ PHPAPI void php_session_start(void) /* {{{ */
|
||||
PS(define_sid) = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (PS(define_sid) && !PS(id) && (data = zend_hash_str_find(&EG(symbol_table), "_GET", sizeof("_GET") - 1))) {
|
||||
ZVAL_DEREF(data);
|
||||
if (Z_TYPE_P(data) == IS_ARRAY && (ppid = zend_hash_str_find(Z_ARRVAL_P(data), PS(session_name), lensess))) {
|
||||
ppid2sid(ppid);
|
||||
/* Initilize session ID from non cookie values */
|
||||
if (!PS(use_only_cookies)) {
|
||||
if (!PS(id) && (data = zend_hash_str_find(&EG(symbol_table), "_GET", sizeof("_GET") - 1))) {
|
||||
ZVAL_DEREF(data);
|
||||
if (Z_TYPE_P(data) == IS_ARRAY && (ppid = zend_hash_str_find(Z_ARRVAL_P(data), PS(session_name), lensess))) {
|
||||
ppid2sid(ppid);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (PS(define_sid) && !PS(id) && (data = zend_hash_str_find(&EG(symbol_table), "_POST", sizeof("_POST") - 1))) {
|
||||
ZVAL_DEREF(data);
|
||||
if (Z_TYPE_P(data) == IS_ARRAY && (ppid = zend_hash_str_find(Z_ARRVAL_P(data), PS(session_name), lensess))) {
|
||||
ppid2sid(ppid);
|
||||
if (!PS(id) && (data = zend_hash_str_find(&EG(symbol_table), "_POST", sizeof("_POST") - 1))) {
|
||||
ZVAL_DEREF(data);
|
||||
if (Z_TYPE_P(data) == IS_ARRAY && (ppid = zend_hash_str_find(Z_ARRVAL_P(data), PS(session_name), lensess))) {
|
||||
ppid2sid(ppid);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Check the REQUEST_URI symbol for a string of the form
|
||||
* '<session-name>=<session-id>' to allow URLs of the form
|
||||
* http://yoursite/<session-name>=<session-id>/script.php */
|
||||
if (PS(define_sid) && !PS(id) &&
|
||||
zend_is_auto_global_str("_SERVER", sizeof("_SERVER") - 1) == SUCCESS &&
|
||||
(data = zend_hash_str_find(Z_ARRVAL(PG(http_globals)[TRACK_VARS_SERVER]), "REQUEST_URI", sizeof("REQUEST_URI") - 1)) &&
|
||||
Z_TYPE_P(data) == IS_STRING &&
|
||||
(p = strstr(Z_STRVAL_P(data), PS(session_name))) &&
|
||||
p[lensess] == '='
|
||||
) {
|
||||
char *q;
|
||||
p += lensess + 1;
|
||||
if ((q = strpbrk(p, "/?\\"))) {
|
||||
PS(id) = zend_string_init(p, q - p, 0);
|
||||
/* Check the REQUEST_URI symbol for a string of the form
|
||||
* '<session-name>=<session-id>' to allow URLs of the form
|
||||
* http://yoursite/<session-name>=<session-id>/script.php */
|
||||
if (!PS(id) && zend_is_auto_global_str("_SERVER", sizeof("_SERVER") - 1) == SUCCESS &&
|
||||
(data = zend_hash_str_find(Z_ARRVAL(PG(http_globals)[TRACK_VARS_SERVER]), "REQUEST_URI", sizeof("REQUEST_URI") - 1)) &&
|
||||
Z_TYPE_P(data) == IS_STRING &&
|
||||
(p = strstr(Z_STRVAL_P(data), PS(session_name))) &&
|
||||
p[lensess] == '='
|
||||
) {
|
||||
char *q;
|
||||
p += lensess + 1;
|
||||
if ((q = strpbrk(p, "/?\\"))) {
|
||||
PS(id) = zend_string_init(p, q - p, 0);
|
||||
}
|
||||
}
|
||||
/* Check whether the current request was referred to by
|
||||
* an external site which invalidates the previously found id. */
|
||||
if (PS(id) && PS(extern_referer_chk)[0] != '\0' &&
|
||||
!Z_ISUNDEF(PG(http_globals)[TRACK_VARS_SERVER]) &&
|
||||
(data = zend_hash_str_find(Z_ARRVAL(PG(http_globals)[TRACK_VARS_SERVER]), "HTTP_REFERER", sizeof("HTTP_REFERER") - 1)) &&
|
||||
Z_TYPE_P(data) == IS_STRING &&
|
||||
Z_STRLEN_P(data) != 0 &&
|
||||
strstr(Z_STRVAL_P(data), PS(extern_referer_chk)) == NULL
|
||||
) {
|
||||
zend_string_release(PS(id));
|
||||
PS(id) = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/* Check whether the current request was referred to by
|
||||
* an external site which invalidates the previously found id. */
|
||||
if (PS(define_sid) && PS(id) &&
|
||||
PS(extern_referer_chk)[0] != '\0' &&
|
||||
!Z_ISUNDEF(PG(http_globals)[TRACK_VARS_SERVER]) &&
|
||||
(data = zend_hash_str_find(Z_ARRVAL(PG(http_globals)[TRACK_VARS_SERVER]), "HTTP_REFERER", sizeof("HTTP_REFERER") - 1)) &&
|
||||
Z_TYPE_P(data) == IS_STRING &&
|
||||
Z_STRLEN_P(data) != 0 &&
|
||||
strstr(Z_STRVAL_P(data), PS(extern_referer_chk)) == NULL
|
||||
) {
|
||||
zend_string_release(PS(id));
|
||||
PS(id) = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user