summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Mark Bell <jmb@netsurf-browser.org>2006-04-12 23:23:47 +0000
committerJohn Mark Bell <jmb@netsurf-browser.org>2006-04-12 23:23:47 +0000
commit1b48febd2f1c5fb66140ed9832a8eafe0cb5bf6f (patch)
tree59c250b61ca02c4ed0c0c36cfb9b1aeade22e95a
parentd453fa3206c719e1f4c18b5cedf5d6a278095e93 (diff)
downloadnetsurf-1b48febd2f1c5fb66140ed9832a8eafe0cb5bf6f.tar.gz
netsurf-1b48febd2f1c5fb66140ed9832a8eafe0cb5bf6f.tar.bz2
Fix issues with authentication storage/lookup in database
svn path=/trunk/netsurf/; revision=2527
-rw-r--r--content/urldb.c26
1 files changed, 22 insertions, 4 deletions
diff --git a/content/urldb.c b/content/urldb.c
index 8782c0e89..5a0260405 100644
--- a/content/urldb.c
+++ b/content/urldb.c
@@ -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);
+ 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(url);
+ urldb_add_url(urlt);
+
+ p = urldb_find_url(urlt);
+
+ free(urlt);
- p = urldb_find_url(url);
if (!p)
return;