From 70b64aebbe9a9f8faf7b7ec316e3b09fac083967 Mon Sep 17 00:00:00 2001 From: "valeski%netscape.com" Date: Sat, 20 Nov 1999 21:46:23 +0000 Subject: [PATCH] not in build. updated auth engine --- netwerk/protocol/http/src/nsAuthEngine.cpp | 26 ++++++++++++++++------ 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/netwerk/protocol/http/src/nsAuthEngine.cpp b/netwerk/protocol/http/src/nsAuthEngine.cpp index ebaf02deab9d..0ce318efd38e 100644 --- a/netwerk/protocol/http/src/nsAuthEngine.cpp +++ b/netwerk/protocol/http/src/nsAuthEngine.cpp @@ -61,15 +61,21 @@ nsAuthEngine::GetAuthString(nsIURI* i_URI, char** o_AuthString) PRInt32 port; rv = i_URI->GetPort(&port); if (NS_FAILED(rv)) return rv; - nsXPIDLCString path; - rv = i_URI->GetPath(getter_Copies(path)); + nsXPIDLCString dir; + rv = i_URI->GetPath(getter_Copies(dir)); + + // remove everything after the last slash + // so we're comparing raw dirs + char *lastSlash = PL_strrchr(dir, '/'); + if (lastSlash) lastSlash[1] = '\0'; + if (NS_FAILED(rv)) return rv; PRUint32 count=0; (void)mAuthList->Count(&count); if (count<=0) return NS_OK; // not found - for (PRUint32 i = count-1; i>=0; --i) + for (PRInt32 i = count-1; i>=0; --i) { nsAuth* auth = (nsAuth*)mAuthList->ElementAt(i); // perfect match case @@ -101,15 +107,21 @@ nsAuthEngine::GetAuthString(nsIURI* i_URI, char** o_AuthString) */ nsXPIDLCString authHost; PRInt32 authPort; - nsXPIDLCString authPath; + nsXPIDLCString authDir; (void)auth->uri->GetHost(getter_Copies(authHost)); (void)auth->uri->GetPort(&authPort); - (void)auth->uri->GetPath(getter_Copies(authPath)); + (void)auth->uri->GetPath(getter_Copies(authDir)); + + // remove everything after the last slash + // so we're comparing raw dirs + lastSlash = PL_strrchr(authDir, '/'); + if (lastSlash) lastSlash[1] = '\0'; + if ((0 == PL_strncasecmp(authHost, host, PL_strlen(authHost))) && (port == authPort) && - (0 == PL_strncasecmp(authPath, path, - PL_strlen(authPath)))) + (0 == PL_strncasecmp(authDir, dir, + PL_strlen(authDir)))) { *o_AuthString = nsCRT::strdup(auth->encodedString); if (!*o_AuthString) return NS_ERROR_OUT_OF_MEMORY;