summaryrefslogtreecommitdiff
path: root/content
diff options
context:
space:
mode:
Diffstat (limited to 'content')
-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;