diff options
author | Yasuo Ohgaki <yohgaki@php.net> | 2016-09-01 07:47:27 +0900 |
---|---|---|
committer | Yasuo Ohgaki <yohgaki@php.net> | 2016-09-01 07:47:27 +0900 |
commit | 90352bb4a2c96321c52f1b3c591583a64ce72f1a (patch) | |
tree | f91ae1c803550ed1ad013b6563bf7bc2908024b5 /ext/session | |
parent | 355c7e7d1cdc180d368c6214ea7605443fc88c92 (diff) | |
parent | cc797d4fc3e6de1a21cbe91f810767cc491c7696 (diff) | |
download | php-git-90352bb4a2c96321c52f1b3c591583a64ce72f1a.tar.gz |
Merge branch 'PHP-7.0' into PHP-7.1
* PHP-7.0:
Fix bug #72940 properly. Reduce needless branches
Diffstat (limited to 'ext/session')
-rw-r--r-- | ext/session/session.c | 79 |
1 files changed, 38 insertions, 41 deletions
diff --git a/ext/session/session.c b/ext/session/session.c index ed5e64ed2a..1bf3586187 100644 --- a/ext/session/session.c +++ b/ext/session/session.c @@ -1479,50 +1479,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; } } |