diff --git a/mailnews/addrbook/src/nsAbDirProperty.h b/mailnews/addrbook/src/nsAbDirProperty.h index 0958067314d5..326fc71756f8 100644 --- a/mailnews/addrbook/src/nsAbDirProperty.h +++ b/mailnews/addrbook/src/nsAbDirProperty.h @@ -84,7 +84,13 @@ protected: nsString m_ListNickName; nsString m_Description; PRBool m_IsMailList; + + /* + * Note that any derived implementations should ensure that this item + * (m_DirPrefId) is correctly initialised correctly + */ nsCString m_DirPrefId; // ie,"ldap_2.servers.pab" + nsCOMPtr m_DirectoryPrefs; nsCOMPtr m_AddressList; }; diff --git a/mailnews/addrbook/src/nsAbLDAPDirectory.cpp b/mailnews/addrbook/src/nsAbLDAPDirectory.cpp index 281fb5b828b3..fa5802d1a79f 100644 --- a/mailnews/addrbook/src/nsAbLDAPDirectory.cpp +++ b/mailnews/addrbook/src/nsAbLDAPDirectory.cpp @@ -84,6 +84,21 @@ NS_IMPL_ISUPPORTS_INHERITED4(nsAbLDAPDirectory, nsAbDirectoryRDFResource, nsIAbD NS_IMETHODIMP nsAbLDAPDirectory::Init(const char* aURI) { mInitialized = PR_FALSE; + + // We need to ensure that the m_DirPrefId is initialized properly + nsCAutoString uri(aURI); + + // Find the first ? (of the search params) if there is one. + // We know we can start at the end of the moz-abldapdirectory:// because + // that's the URI we should have been passed. + PRInt32 searchCharLocation = uri.FindChar('?', kLDAPDirectoryRootLen); + + if (searchCharLocation == kNotFound) + uri.Right(m_DirPrefId, uri.Length() - kLDAPDirectoryRootLen); + else + uri.Mid(m_DirPrefId, kLDAPDirectoryRootLen, + searchCharLocation - kLDAPDirectoryRootLen); + return nsAbDirectoryRDFResource::Init(aURI); } @@ -623,4 +638,3 @@ NS_IMETHODIMP nsAbLDAPDirectory::SetDataVersion(const nsACString &aDataVersion) { return SetStringValue("dataVersion", aDataVersion); } -