Mercurial > urweb
changeset 1051:731e6aa6655a
Port rest of demo to new cookie signature; fix parsing of multiple incoming cookies
author | Adam Chlipala <adamc@hcoop.net> |
---|---|
date | Thu, 26 Nov 2009 14:58:03 -0500 |
parents | 93315ac00394 |
children | 7e3226c97678 |
files | demo/cookieSec.ur src/c/urweb.c |
diffstat | 2 files changed, 13 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/demo/cookieSec.ur Thu Nov 26 14:20:00 2009 -0500 +++ b/demo/cookieSec.ur Thu Nov 26 14:58:03 2009 -0500 @@ -25,7 +25,7 @@ </body></xml> and set r = - setCookie username r.User; + setCookie username {Value = r.User, Expires = None, Secure = False}; main () and imHere () =
--- a/src/c/urweb.c Thu Nov 26 14:20:00 2009 -0500 +++ b/src/c/urweb.c Thu Nov 26 14:58:03 2009 -0500 @@ -2667,10 +2667,19 @@ } if (p = uw_Basis_requestHeader(ctx, "Cookie")) { + char *p2; + while (1) { - if (!strncmp(p, c, len) && p[len] == '=') - return p + 1 + len; - else if (p = strchr(p, ';')) + if (!strncmp(p, c, len) && p[len] == '=') { + if (p2 = strchr(p, ';')) { + size_t n = p2 - (p + len); + char *r = uw_malloc(ctx, n); + memcpy(r, p + 1 + len, n-1); + r[n-1] = 0; + return r; + } else + return p + 1 + len; + } else if (p = strchr(p, ';')) p += 2; else return NULL;