]> granicus.if.org Git - php/commitdiff
Fixed bug #69983 (get_browser fails with user agent of null)
authorXinchen Hui <laruence@php.net>
Sat, 4 Jul 2015 03:05:50 +0000 (11:05 +0800)
committerXinchen Hui <laruence@php.net>
Sat, 4 Jul 2015 03:05:50 +0000 (11:05 +0800)
NEWS
ext/standard/browscap.c
ext/standard/tests/misc/bug69983.phpt [new file with mode: 0644]

diff --git a/NEWS b/NEWS
index fb3a6f2ad4e0bba0a7063f89f53b0051e3caad93..73c5afcaf376d0f40053bdd813cd1250c635bfbf 100644 (file)
--- 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)
 
index 193ee744368575f44954bbb9fb88e6667f15a271..86d1cf58358ba39463cd8911592f1cf9ac1be281 100644 (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");
diff --git a/ext/standard/tests/misc/bug69983.phpt b/ext/standard/tests/misc/bug69983.phpt
new file mode 100644 (file)
index 0000000..3a0925c
--- /dev/null
@@ -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
+)