Skip to content
Snippets Groups Projects
Commit 3409e556 authored by Russell Bryant's avatar Russell Bryant
Browse files

Fix cookie parsing for Internet Explorer (issue #7454, jeff)

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@40131 65c4cc65-6c06-0410-ace0-fbb531ad65f3
parent c4bd88d6
No related branches found
No related tags found
No related merge requests found
...@@ -394,23 +394,50 @@ static void *ast_httpd_helper_thread(void *data) ...@@ -394,23 +394,50 @@ static void *ast_httpd_helper_thread(void *data)
if (ast_strlen_zero(cookie)) if (ast_strlen_zero(cookie))
break; break;
if (!strncasecmp(cookie, "Cookie: ", 8)) { if (!strncasecmp(cookie, "Cookie: ", 8)) {
vname = cookie + 8;
vval = strchr(vname, '='); /* TODO - The cookie parsing code below seems to work
if (vval) { in IE6 and FireFox 1.5. However, it is not entirely
/* Ditch the = and the quotes */ correct, and therefore may not work in all
*vval = '\0'; circumstances.
vval++; For more details see RFC 2109 and RFC 2965 */
if (*vval)
vval++; /* FireFox cookie strings look like:
if (strlen(vval)) Cookie: mansession_id="********"
vval[strlen(vval) - 1] = '\0'; InternetExplorer's look like:
var = ast_variable_new(vname, vval); Cookie: $Version="1"; mansession_id="********" */
if (var) {
if (prev) /* If we got a FireFox cookie string, the name's right
prev->next = var; after "Cookie: " */
else vname = cookie + 8;
vars = var;
prev = var; /* If we got an IE cookie string, we need to skip to
past the version to get to the name */
if (*vname == '$') {
vname = strchr(vname, ';');
if (vname) {
vname++;
if (*vname == ' ')
vname++;
}
}
if (vname) {
vval = strchr(vname, '=');
if (vval) {
/* Ditch the = and the quotes */
*vval++ = '\0';
if (*vval)
vval++;
if (strlen(vval))
vval[strlen(vval) - 1] = '\0';
var = ast_variable_new(vname, vval);
if (var) {
if (prev)
prev->next = var;
else
vars = var;
prev = var;
}
} }
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment