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

Michael Niedermayer michaelni at gmx.at
Tue Feb 25 10:00:41 CET 2014


On Mon, Feb 24, 2014 at 09:57:15PM -0800, Scott Moak wrote:
> 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 | 17 ++++++++++++++---
>  1 file changed, 14 insertions(+), 3 deletions(-)
> 
> diff --git a/libavformat/http.c b/libavformat/http.c
> index 69c4d6d..72ab4ca 100644
> --- a/libavformat/http.c
> +++ b/libavformat/http.c
> @@ -484,8 +484,18 @@ 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, " ");
> +            /* skip trailing spaces */
> +            if (strlen(param) > 0) {
> +                char *end = param + strlen(param) - 1;
> +                while (end > param && av_isspace(*end)) {


changing this to av_isspace() might make sense, i dont know but
that should be in a seperate patch and probably should be done
to both sides of the token
previously only " " was removed

also something like this would be shorter, if it works ?

char *end = param + strlen(param);
while(*param && (*--end) == ' ')
    *end = 0;

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

There will always be a question for which you do not know the correct answer.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20140225/51185a0d/attachment.asc>


More information about the ffmpeg-devel mailing list