summaryrefslogtreecommitdiff
path: root/ext/standard/browscap.c
diff options
context:
space:
mode:
authorJani Taskinen <jani@php.net>2009-11-24 00:18:16 +0000
committerJani Taskinen <jani@php.net>2009-11-24 00:18:16 +0000
commitebc1b9f13d9bcabb335ea9002d9b470ba39e112d (patch)
tree2cdc3cf706a39a497d3ec99def916f66ed5f7cbe /ext/standard/browscap.c
parenta83156d5c12e671439da27f254de7462811793b5 (diff)
downloadphp-git-ebc1b9f13d9bcabb335ea9002d9b470ba39e112d.tar.gz
Fixed bug #50267 (get_browser(null) does not use HTTP_USER_AGENT)
Diffstat (limited to 'ext/standard/browscap.c')
-rw-r--r--ext/standard/browscap.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/ext/standard/browscap.c b/ext/standard/browscap.c
index 61857e59c9..41e9c46d41 100644
--- a/ext/standard/browscap.c
+++ b/ext/standard/browscap.c
@@ -328,7 +328,7 @@ PHP_FUNCTION(get_browser)
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 @@ PHP_FUNCTION(get_browser)
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);