jani                                     Tue, 24 Nov 2009 00:18:16 +0000

Revision: http://svn.php.net/viewvc?view=revision&revision=291250

Log:
Fixed bug #50267 (get_browser(null) does not use HTTP_USER_AGENT)

Bug: http://bugs.php.net/50267 (Feedback) get_browser with null parameter runs 
on empty user agent string
      
Changed paths:
    U   php/php-src/branches/PHP_5_3/NEWS
    U   php/php-src/branches/PHP_5_3/ext/standard/browscap.c
    U   php/php-src/trunk/ext/standard/browscap.c

Modified: php/php-src/branches/PHP_5_3/NEWS
===================================================================
--- php/php-src/branches/PHP_5_3/NEWS   2009-11-23 23:57:27 UTC (rev 291249)
+++ php/php-src/branches/PHP_5_3/NEWS   2009-11-24 00:18:16 UTC (rev 291250)
@@ -24,6 +24,7 @@
 - Fixed memory leak in extension loading when an error occurs on Windows.
   (Pierre)

+- Fixed bug #50267 (get_browser(null) does not use HTTP_USER_AGENT). (Jani)
 - Fixed bug #50240 (pdo_mysql.default_socket in php.ini shouldn't used
   if it is empty). (foutrelis at gmail dot com, Ilia)
 - Fixed bug #50219 (soap call Segmentation fault on a redirected url).

Modified: php/php-src/branches/PHP_5_3/ext/standard/browscap.c
===================================================================
--- php/php-src/branches/PHP_5_3/ext/standard/browscap.c        2009-11-23 
23:57:27 UTC (rev 291249)
+++ php/php-src/branches/PHP_5_3/ext/standard/browscap.c        2009-11-24 
00:18:16 UTC (rev 291250)
@@ -328,7 +328,7 @@
        char *agent_name = NULL;
        int agent_name_len = 0;
        zend_bool return_array = 0;
-       zval **agent, **z_agent_name;
+       zval **agent, **z_agent_name, **http_user_agent;
        zval *found_browser_entry, *tmp_copy;
        char *lookup_browser_name;
        char *browscap = INI_STR("browscap");
@@ -344,11 +344,14 @@

        if (agent_name == NULL) {
                zend_is_auto_global("_SERVER", sizeof("_SERVER") - 1 TSRMLS_CC);
-               if (!PG(http_globals)[TRACK_VARS_SERVER]
-                       || 
zend_hash_find(PG(http_globals)[TRACK_VARS_SERVER]->value.ht, 
"HTTP_USER_AGENT", sizeof("HTTP_USER_AGENT"), (void **) &agent_name) == 
FAILURE) {
+               if (!PG(http_globals)[TRACK_VARS_SERVER] ||
+                       
zend_hash_find(HASH_OF(PG(http_globals)[TRACK_VARS_SERVER]), "HTTP_USER_AGENT", 
sizeof("HTTP_USER_AGENT"), (void **) &http_user_agent) == FAILURE
+               ) {
                        php_error_docref(NULL TSRMLS_CC, E_WARNING, 
"HTTP_USER_AGENT variable is not set, cannot determine user agent name");
                        RETURN_FALSE;
                }
+               agent_name = Z_STRVAL_PP(http_user_agent);
+               agent_name_len = Z_STRLEN_PP(http_user_agent);
        }

        lookup_browser_name = estrndup(agent_name, agent_name_len);

Modified: php/php-src/trunk/ext/standard/browscap.c
===================================================================
--- php/php-src/trunk/ext/standard/browscap.c   2009-11-23 23:57:27 UTC (rev 
291249)
+++ php/php-src/trunk/ext/standard/browscap.c   2009-11-24 00:18:16 UTC (rev 
291250)
@@ -328,7 +328,7 @@
        char *agent_name = NULL;
        int agent_name_len = 0;
        zend_bool return_array = 0;
-       zval **agent, **z_agent_name;
+       zval **agent, **z_agent_name, **http_user_agent;
        zval *found_browser_entry, *tmp_copy;
        char *lookup_browser_name;
        char *browscap = INI_STR("browscap");
@@ -344,11 +344,14 @@

        if (agent_name == NULL) {
                zend_is_auto_global("_SERVER", sizeof("_SERVER") - 1 TSRMLS_CC);
-               if (!PG(http_globals)[TRACK_VARS_SERVER]
-                       || 
zend_hash_find(PG(http_globals)[TRACK_VARS_SERVER]->value.ht, 
"HTTP_USER_AGENT", sizeof("HTTP_USER_AGENT"), (void **) &agent_name) == 
FAILURE) {
+               if (!PG(http_globals)[TRACK_VARS_SERVER] ||
+                       
zend_hash_find(HASH_OF(PG(http_globals)[TRACK_VARS_SERVER]), "HTTP_USER_AGENT", 
sizeof("HTTP_USER_AGENT"), (void **) &http_user_agent) == FAILURE
+               ) {
                        php_error_docref(NULL TSRMLS_CC, E_WARNING, 
"HTTP_USER_AGENT variable is not set, cannot determine user agent name");
                        RETURN_FALSE;
                }
+               agent_name = Z_STRVAL_PP(http_user_agent);
+               agent_name_len = Z_STRLEN_PP(http_user_agent);
        }

        lookup_browser_name = estrndup(agent_name, agent_name_len);

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to