mirror of
https://github.com/netsurf-browser/netsurf
synced 2024-12-22 20:16:54 +03:00
Minor fix for path defaulting: retain rightmost / iff it's the first character in the path
svn path=/trunk/netsurf/; revision=11524
This commit is contained in:
parent
850160c40f
commit
27924aa38c
@ -2954,7 +2954,7 @@ struct cookie_internal_data *urldb_parse_cookie(const char *url,
|
||||
assert(url && cookie && *cookie);
|
||||
|
||||
c = calloc(1, sizeof(struct cookie_internal_data));
|
||||
if (!c)
|
||||
if (c == NULL)
|
||||
return NULL;
|
||||
|
||||
c->expires = -1;
|
||||
@ -3140,7 +3140,7 @@ struct cookie_internal_data *urldb_parse_cookie(const char *url,
|
||||
}
|
||||
|
||||
/* Now fix-up default values */
|
||||
if (!c->domain) {
|
||||
if (c->domain == NULL) {
|
||||
res = url_host(url, &c->domain);
|
||||
if (res != URL_FUNC_OK) {
|
||||
urldb_free_cookie(c);
|
||||
@ -3148,7 +3148,7 @@ struct cookie_internal_data *urldb_parse_cookie(const char *url,
|
||||
}
|
||||
}
|
||||
|
||||
if (!c->path) {
|
||||
if (c->path == NULL) {
|
||||
char *path;
|
||||
char *slash;
|
||||
|
||||
@ -3160,7 +3160,11 @@ struct cookie_internal_data *urldb_parse_cookie(const char *url,
|
||||
|
||||
/* Strip leafname and trailing slash (4.3.1) */
|
||||
slash = strrchr(path, '/');
|
||||
if (slash) {
|
||||
if (slash != NULL) {
|
||||
/* Special case: retain first slash in path */
|
||||
if (slash == path)
|
||||
slash++;
|
||||
|
||||
slash = strndup(path, slash - path);
|
||||
if (slash == NULL) {
|
||||
free(path);
|
||||
|
@ -190,6 +190,11 @@ int main(void)
|
||||
assert(urldb_set_cookie("name=value\r\n", "http://www.example.org/foo/bar/baz/bat.html", NULL));
|
||||
assert(urldb_get_cookie("http://www.example.org/foo/bar/baz/quux.htm"));
|
||||
|
||||
/* Defaulted path with no non-leaf path segments */
|
||||
assert(urldb_set_cookie("name=value\r\n", "http://no-non-leaf.example.org/index.html", NULL));
|
||||
assert(urldb_get_cookie("http://no-non-leaf.example.org/page2.html"));
|
||||
assert(urldb_get_cookie("http://no-non-leaf.example.org/"));
|
||||
|
||||
/* Valid path (includes leafname) */
|
||||
assert(urldb_set_cookie("name=value;Version=1;Path=/index.cgi\r\n", "http://example.org/index.cgi", NULL));
|
||||
assert(urldb_get_cookie("http://example.org/index.cgi"));
|
||||
|
Loading…
Reference in New Issue
Block a user