mirror of https://git.ffmpeg.org/ffmpeg.git
lavf/http: fix cookie parsing.
The current code would use any unknown attribute-value pair as the cookie value. RFC 6265 states that the first key-value pair is the actual cookie, and the attribute-value pairs only start after. With the current code: Set-Cookie: test=good_value; path=/; dummy=42 gives this: Cookie: dummy=42 instead of this with the new code: Cookie: test=good_value
This commit is contained in:
parent
94f60b6544
commit
481cbc5ad5
|
@ -565,8 +565,11 @@ static int get_cookies(HTTPContext *s, char **cookies, const char *path,
|
||||||
set_cookies = NULL;
|
set_cookies = NULL;
|
||||||
|
|
||||||
while ((param = av_strtok(cookie, "; ", &next_param))) {
|
while ((param = av_strtok(cookie, "; ", &next_param))) {
|
||||||
|
if (cookie) {
|
||||||
|
// first key-value pair is the actual cookie value
|
||||||
|
cvalue = av_strdup(param);
|
||||||
cookie = NULL;
|
cookie = NULL;
|
||||||
if (!av_strncasecmp("path=", param, 5)) {
|
} else if (!av_strncasecmp("path=", param, 5)) {
|
||||||
av_free(cpath);
|
av_free(cpath);
|
||||||
cpath = av_strdup(¶m[5]);
|
cpath = av_strdup(¶m[5]);
|
||||||
} else if (!av_strncasecmp("domain=", param, 7)) {
|
} else if (!av_strncasecmp("domain=", param, 7)) {
|
||||||
|
@ -581,8 +584,7 @@ static int get_cookies(HTTPContext *s, char **cookies, const char *path,
|
||||||
!av_strncasecmp("version", param, 7)) {
|
!av_strncasecmp("version", param, 7)) {
|
||||||
// ignore Comment, Max-Age, Secure and Version
|
// ignore Comment, Max-Age, Secure and Version
|
||||||
} else {
|
} else {
|
||||||
av_free(cvalue);
|
// ignore unknown attributes
|
||||||
cvalue = av_strdup(param);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!cdomain)
|
if (!cdomain)
|
||||||
|
|
Loading…
Reference in New Issue