com php-src: Fixed bug #69983 (get_browser fails with user agent of null): NEWS ext/standard/browsca p.c ext/standard/tests/misc/bug69983.phpt
| From: | Xinchen Hui | Date: | Sat, 04 Jul 2015 03:05:50 +0000 |
| Subject: | com php-src: Fixed bug #69983 (get_browser fails with user agent of null): NEWS ext/standard/browsca p.c ext/standard/tests/misc/bug69983.phpt | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-87743@lists.php.net to get a copy of this message | ||
Commit: 550bbf8f4614a5c868010195f562be3e9ee6bb00
Author: Xinchen Hui <laruence@php.net> Sat, 4 Jul 2015 11:05:50 +0800
Parents: 1a0ddf988c92614de6890c12ee305c4bf1ff4302
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=550bbf8f4614a5c868010195f562be3e9ee6bb00
Log:
Fixed bug #69983 (get_browser fails with user agent of null)
Bugs:
https://bugs.php.net/69983
Changed paths:
M NEWS
M ext/standard/browscap.c
A ext/standard/tests/misc/bug69983.phpt
Diff:
diff --git a/NEWS b/NEWS
index fb3a6f2...73c5afc 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 193ee74..86d1cf5 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 0000000..3a0925c
--- /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--
+<?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
+)