Fixed bug #69983 (get_browser fails with user agent of null)

This commit is contained in:
Xinchen Hui 2015-07-04 11:05:50 +08:00
parent 1a0ddf988c
commit 550bbf8f46
3 changed files with 52 additions and 1 deletions

2
NEWS
View file

@ -42,6 +42,8 @@ PHP NEWS
reference). (Bob)
- Standard:
. Fixed bug #69983 (get_browser fails with user agent of null).
(Kalle, cmb, Laruence)
. Fixed bug #69976 (Unable to parse "all" urls with colon char). (cmb)
. Fixed bug #69768 (escapeshell*() doesn't cater to !). (cmb)

View file

@ -462,7 +462,7 @@ PHP_FUNCTION(get_browser)
}
if (agent_name == NULL) {
if ((Z_TYPE(PG(http_globals)[TRACK_VARS_SERVER]) == IS_ARRAY || zend_is_auto_global_str(ZEND_STRL("_SERVER"))) ||
if ((Z_TYPE(PG(http_globals)[TRACK_VARS_SERVER]) == IS_ARRAY || zend_is_auto_global_str(ZEND_STRL("_SERVER"))) &&
(http_user_agent = zend_hash_str_find(Z_ARRVAL_P(&PG(http_globals)[TRACK_VARS_SERVER]), "HTTP_USER_AGENT", sizeof("HTTP_USER_AGENT")-1)) == NULL
) {
php_error_docref(NULL, E_WARNING, "HTTP_USER_AGENT variable is not set, cannot determine user agent name");

View file

@ -0,0 +1,49 @@
--TEST--
Bug #69983 (get_browser fails with user agent of null)
--INI--
browscap={PWD}/browscap.ini
--ENV--
HTTP_USER_AGENT="Opera/7.11 (Windows NT 5.1; U) [en]"
--FILE--
<?php
$browser=get_browser(NULL, true);
print_r($browser);
?>
--EXPECT--
Array
(
[browser_name_regex] => ~^.*$~
[browser_name_pattern] => *
[browser] => Default Browser
[version] => 0
[majorver] => 0
[minorver] => 0
[platform] => unknown
[alpha] =>
[beta] =>
[win16] =>
[win32] =>
[win64] =>
[frames] => 1
[iframes] =>
[tables] => 1
[cookies] =>
[backgroundsounds] =>
[authenticodeupdate] => 0
[cdf] =>
[vbscript] =>
[javaapplets] =>
[javascript] =>
[activexcontrols] =>
[stripper] =>
[isbanned] =>
[wap] =>
[ismobiledevice] =>
[issyndicationreader] =>
[crawler] =>
[css] => 0
[cssversion] => 0
[supportscss] =>
[aol] =>
[aolversion] => 0
)