Index: nsXPITriggerInfo.cpp =================================================================== RCS file: /cvsroot/mozilla/xpinstall/src/nsXPITriggerInfo.cpp,v retrieving revision 1.39 diff -up -r1.39 nsXPITriggerInfo.cpp --- nsXPITriggerInfo.cpp +++ nsXPITriggerInfo.cpp @@ -92,23 +92,10 @@ nsXPITriggerItem::nsXPITriggerItem( cons } // parse optional hash into its parts - if (aHash) + if (aHash && PL_strchr(aHash, ':')) { mHashFound = PR_TRUE; - - char * colon = PL_strchr(aHash, ':'); - if (colon) - { - mHasher = do_CreateInstance("@mozilla.org/security/hash;1"); - if (!mHasher) return; - - *colon = '\0'; // null the colon so that aHash is just the type. - nsresult rv = mHasher->InitWithString(nsDependentCString(aHash)); - *colon = ':'; // restore the colon - - if (NS_SUCCEEDED(rv)) - mHash = colon+1; - } + mHash = nsDependentCString(aHash); } } Index: nsXPInstallManager.cpp =================================================================== RCS file: /cvsroot/mozilla/xpinstall/src/nsXPInstallManager.cpp,v retrieving revision 1.156 diff -up -r1.156 nsXPInstallManager.cpp --- nsXPInstallManager.cpp +++ nsXPInstallManager.cpp @@ -761,17 +761,46 @@ NS_IMETHODIMP nsXPInstallManager::Downlo } // If there was hash info in the trigger, but - // there wasn't a hash object created, then the - // algorithm used isn't known. + // there wasn't a hash object created, then + // mHash is the value to use to initialize the + // mHasher. if (mItem->mHashFound && !mItem->mHasher) { - // report failure - mTriggers->SendStatus( mItem->mURL.get(), nsInstall::INVALID_HASH_TYPE ); - if (mDlg) - mDlg->OnStateChange( i, nsIXPIProgressDialog::INSTALL_DONE, - nsInstall::INVALID_HASH_TYPE ); - continue; + PRBool ok = mItem->mHash.IsEmpty(); + PRInt32 colon = mItem->mHash.FindChar(':'); + if (!ok && colon > 0) { + nsCOMPtr hasher(do_CreateInstance("@mozilla.org/security/hash;1")); + + if (hasher) { + rv = hasher->InitWithString(Substring(mItem->mHash, + 0, colon - 1)); + if (NS_SUCCEEDED(rv)) { + mItem->mHash = Substring(mItem->mHash, + colon + 1, + mItem->mHash.Length()); + } else { + hasher = nsnull; + } + } + if (hasher) { + mItem->mHasher = hasher; + } else { + mItem->mHash.Truncate(); + ok = PR_FALSE; + } + } + if (!ok) { + // report failure + mTriggers->SendStatus( mItem->mURL.get(), + nsInstall::INVALID_HASH_TYPE ); + if (mDlg) + mDlg->OnStateChange( i, + nsIXPIProgressDialog::INSTALL_DONE, + nsInstall::INVALID_HASH_TYPE ); + continue; + } + } // Don't install if we can't verify the hash (if specified)