From 550bbf8f4614a5c868010195f562be3e9ee6bb00 Mon Sep 17 00:00:00 2001 From: Xinchen Hui Date: Sat, 4 Jul 2015 11:05:50 +0800 Subject: [PATCH] Fixed bug #69983 (get_browser fails with user agent of null) --- NEWS | 2 ++ ext/standard/browscap.c | 2 +- ext/standard/tests/misc/bug69983.phpt | 49 +++++++++++++++++++++++++++ 3 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 ext/standard/tests/misc/bug69983.phpt diff --git a/NEWS b/NEWS index fb3a6f2ad4..73c5afcaf3 100644 --- a/NEWS +++ b/NEWS @@ -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) diff --git a/ext/standard/browscap.c b/ext/standard/browscap.c index 193ee74436..86d1cf5835 100644 --- a/ext/standard/browscap.c +++ b/ext/standard/browscap.c @@ -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"); diff --git a/ext/standard/tests/misc/bug69983.phpt b/ext/standard/tests/misc/bug69983.phpt new file mode 100644 index 0000000000..3a0925c65a --- /dev/null +++ b/ext/standard/tests/misc/bug69983.phpt @@ -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-- + +--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 +) -- 2.40.0