Fix issues with authentication storage/lookup in database

svn path=/trunk/netsurf/; revision=2527
This commit is contained in:
John Mark Bell 2006-04-12 23:23:47 +00:00
parent d453fa3206
commit 1b48febd2f
1 changed files with 23 additions and 5 deletions

View File

@ -838,7 +838,7 @@ const struct url_data *urldb_get_url_data(const char *url)
*/
const char *urldb_get_auth_details(const char *url)
{
struct path_data *p, *q;
struct path_data *p, *q = NULL;
assert(url);
@ -849,6 +849,11 @@ const char *urldb_get_auth_details(const char *url)
if (!p)
return NULL;
/* Check for any auth details attached to this node */
if (p && p->auth.realm && p->auth.auth)
return p->auth.auth;
/* Now consider ancestors */
for (; p; p = p->parent) {
/* The parent path entry is stored hung off the
* parent entry with an empty (not NULL) segment string.
@ -906,14 +911,27 @@ void urldb_set_auth_details(const char *url, const char *realm,
const char *auth)
{
struct path_data *p;
char *t1, *t2;
char *urlt, *t1, *t2;
assert(url && realm && auth);
/* add url, in case it's missing */
urldb_add_url(url);
urlt = strdup(url);
if (!urlt)
return;
/* strip leafname from URL */
t1 = strrchr(urlt, '/');
if (t1) {
*(t1 + 1) = '\0';
}
/* add url, in case it's missing */
urldb_add_url(urlt);
p = urldb_find_url(urlt);
free(urlt);
p = urldb_find_url(url);
if (!p)
return;