1
0
Fork 0

Merge pull request #44 from aelmahmoudy/cookie-path

cookies: Properly handle cookie path= equal to request path
This commit is contained in:
rkd77 2020-05-10 14:56:17 +02:00 committed by GitHub
commit 3ea14631bb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 4 deletions

View File

@ -356,8 +356,7 @@ set_cookie(struct uri *uri, unsigned char *str)
unsigned char *path_end;
case HEADER_PARAM_FOUND:
if (!path[0]
|| path[strlen(path) - 1] != '/')
if (!path[0])
add_to_strn(&path, "/");
if (path[0] != '/') {
@ -374,7 +373,7 @@ set_cookie(struct uri *uri, unsigned char *str)
path_end = strrchr((const char *)path, '/');
if (path_end)
path_end[1] = '\0';
path_end[0] = '\0';
break;
default: /* error */
@ -615,7 +614,7 @@ is_path_prefix(unsigned char *d, unsigned char *s)
if (dl > strlen(s)) return 0;
return !memcmp(d, s, dl);
return !memcmp(d, s, dl) && (s[dl] == '\0' || s[dl] == '/');
}