[FFmpeg-devel] [PATCH] Parse cookies more correctly

Scott Moak scott.moak at mybrainoncode.com
Sat Feb 8 05:22:53 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 | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/libavformat/http.c b/libavformat/http.c
index 69c4d6d..794a68f 100644
--- a/libavformat/http.c
+++ b/libavformat/http.c
@@ -484,8 +484,10 @@ 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))) {
+        while ((param = av_strtok(cookie, ";", &next_param))) {
             cookie = NULL;
+            /* skip leading spaces */
+            param += strspn(param, " ");
             if        (!av_strncasecmp("path=",   param, 5)) {
                 av_free(cpath);
                 cpath = av_strdup(&param[5]);
@@ -498,8 +500,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