bug 268059 hide URL user:pass in XPinstall dialogs, r/sr=dougt

This commit is contained in:
dveditz%cruzio.com 2005-02-19 08:32:25 +00:00
parent ba3a7e5abf
commit 87c83c4bff
3 changed files with 26 additions and 2 deletions

View File

@ -39,6 +39,7 @@
#include "nscore.h"
#include "nsXPITriggerInfo.h"
#include "nsNetUtil.h"
#include "nsDebug.h"
#include "nsIServiceManager.h"
#include "nsIEventQueueService.h"
@ -105,6 +106,25 @@ PRBool nsXPITriggerItem::IsRelativeURL()
return (cpos > spos);
}
const PRUnichar*
nsXPITriggerItem::GetSafeURLString()
{
// create the safe url string the first time
if (mSafeURL.IsEmpty() && !mURL.IsEmpty())
{
nsCOMPtr<nsIURI> uri;
NS_NewURI(getter_AddRefs(uri), mURL);
if (uri)
{
nsCAutoString spec;
uri->SetUserPass(EmptyCString());
uri->GetSpec(spec);
mSafeURL = NS_ConvertUTF8toUTF16(spec);
}
}
return mSafeURL.get();
}
void
nsXPITriggerItem::SetPrincipal(nsIPrincipal* aPrincipal)

View File

@ -82,16 +82,20 @@ class nsXPITriggerItem
nsCOMPtr<nsILocalFile> mFile;
nsCOMPtr<nsIOutputStream> mOutStream;
nsCOMPtr<nsIPrincipal> mPrincipal;
PRBool IsFileURL() { return StringBeginsWith(mURL, NS_LITERAL_STRING("file:/")); }
PRBool IsRelativeURL();
const PRUnichar* GetSafeURLString();
void SetPrincipal(nsIPrincipal* aPrincipal);
private:
//-- prevent inadvertent copies and assignments
nsXPITriggerItem& operator=(const nsXPITriggerItem& rhs);
nsXPITriggerItem(const nsXPITriggerItem& rhs);
nsString mSafeURL;
};

View File

@ -267,7 +267,7 @@ nsXPInstallManager::InitManagerInternal()
{
nsXPITriggerItem *item = mTriggers->Get(i);
packageList[j++] = item->mName.get();
packageList[j++] = item->mURL.get();
packageList[j++] = item->GetSafeURLString();
packageList[j++] = item->mIconURL.get();
packageList[j++] = item->mCertName.get();
}