[FFmpeg-devel] [PATCH v3] Parse cookies more correctly
Scott Moak
scott.moak at mybrainoncode.com
Thu Feb 13 06:07:42 CET 2014
Cookies with an Expires directive do not get parsed (and ignored)
correctly, so we need to fix that.
Signed-off-by: Scott Moak <scott.moak at mybrainoncode.com>
---
libavformat/http.c | 18 +++++++++++++++---
1 file changed, 15 insertions(+), 3 deletions(-)
diff --git a/libavformat/http.c b/libavformat/http.c
index 69c4d6d..3ea2e55 100644
--- a/libavformat/http.c
+++ b/libavformat/http.c
@@ -484,8 +484,19 @@ static int get_cookies(HTTPContext *s, char **cookies, const char *path,
char *param, *next_param, *cdomain = NULL, *cpath = NULL, *cvalue = NULL;
set_cookies = NULL;
- while ((param = av_strtok(cookie, "; ", &next_param))) {
+ /* skip trailing spaces */
+ while (0x20 == cookie[strlen(cookie) - 1]) {
+ cookie[strlen(cookie) - 1] = 0;
+ }
+
+ while ((param = av_strtok(cookie, ";", &next_param))) {
cookie = NULL;
+ /* skip leading spaces */
+ param += strspn(param, " ");
+ /* skip trailing spaces */
+ while (0x20 == param[strlen(param) - 1]) {
+ param[strlen(param) - 1] = 0;
+ }
if (!av_strncasecmp("path=", param, 5)) {
av_free(cpath);
cpath = av_strdup(¶m[5]);
@@ -498,8 +509,9 @@ static int get_cookies(HTTPContext *s, char **cookies, const char *path,
} else if (!av_strncasecmp("secure", param, 6) ||
!av_strncasecmp("comment", param, 7) ||
!av_strncasecmp("max-age", param, 7) ||
- !av_strncasecmp("version", param, 7)) {
- // ignore Comment, Max-Age, Secure and Version
+ !av_strncasecmp("version", param, 7) ||
+ !av_strncasecmp("expires", param, 7)) {
+ // ignore Comment, Max-Age, Secure, Version and Expires
} else {
av_free(cvalue);
cvalue = av_strdup(param);
--
1.8.5.4
More information about the ffmpeg-devel
mailing list