This commit is contained in:
Asaf Romano 2008-11-18 22:13:12 +02:00
Родитель 1fe6775572 984229a6b0
Коммит 45d38bfebb
3 изменённых файлов: 36 добавлений и 24 удалений

Просмотреть файл

@ -1953,11 +1953,16 @@ SessionStoreService.prototype = {
return;
}
// always call this before injecting content into a document!
function hasExpectedURL(aDocument, aURL)
!aURL || aURL.replace(/#.*/, "") == aDocument.location.href.replace(/#.*/, "");
// restore text data saved by Firefox 2.0/3.0
var textArray = this.__SS_restore_text ? this.__SS_restore_text.split(" ") : [];
function restoreTextData(aContent, aPrefix) {
function restoreTextData(aContent, aPrefix, aURL) {
textArray.forEach(function(aEntry) {
if (/^((?:\d+\|)*)(#?)([^\s=]+)=(.*)$/.test(aEntry) && RegExp.$1 == aPrefix) {
if (/^((?:\d+\|)*)(#?)([^\s=]+)=(.*)$/.test(aEntry) &&
RegExp.$1 == aPrefix && hasExpectedURL(aContent.document, aURL)) {
var document = aContent.document;
var node = RegExp.$2 ? document.getElementById(RegExp.$3) : document.getElementsByName(RegExp.$3)[0] || null;
if (node && "value" in node) {
@ -1971,8 +1976,11 @@ SessionStoreService.prototype = {
});
}
function restoreFormData(aDocument, aData) {
function restoreFormData(aDocument, aData, aURL) {
for (let key in aData) {
if (!hasExpectedURL(aDocument, aURL))
return;
let node = key.charAt(0) == "#" ? aDocument.getElementById(key.slice(1)) :
XPathHelper.resolve(aDocument, key);
if (!node)
@ -2002,18 +2010,19 @@ SessionStoreService.prototype = {
}
let selectedPageStyle = this.__SS_restore_pageStyle;
let window = this.ownerDocument.defaultView;
function restoreTextDataAndScrolling(aContent, aData, aPrefix) {
if (aData.formdata)
restoreFormData(aContent.document, aData.formdata);
restoreFormData(aContent.document, aData.formdata, aData.url);
else
restoreTextData(aContent, aPrefix);
restoreTextData(aContent, aPrefix, aData.url);
if (aData.innerHTML) {
aContent.setTimeout(
function(aHTML) {
if (aContent.document.designMode == "on") {
aContent.document.body.innerHTML = aHTML;
}
}, 0, aData.innerHTML);
window.setTimeout(function() {
if (aContent.document.designMode == "on" &&
hasExpectedURL(aContent.document, aData.url)) {
aContent.document.body.innerHTML = aData.innerHTML;
}
}, 0);
}
if (aData.scroll && /(\d+),(\d+)/.test(aData.scroll)) {
aContent.scrollTo(RegExp.$1, RegExp.$2);
@ -2022,7 +2031,8 @@ SessionStoreService.prototype = {
aSS.disabled = aSS.title && aSS.title != selectedPageStyle;
});
for (var i = 0; i < aContent.frames.length; i++) {
if (aData.children && aData.children[i]) {
if (aData.children && aData.children[i] &&
hasExpectedURL(aContent.document, aData.url)) {
restoreTextDataAndScrolling(aContent.frames[i], aData.children[i], aPrefix + i + "|");
}
}
@ -2030,8 +2040,7 @@ SessionStoreService.prototype = {
// don't restore text data and scrolling state if the user has navigated
// away before the loading completed (except for in-page navigation)
if (!this.__SS_restore_data.url || this.currentURI.spec.replace(/#.*/, "") ==
this.__SS_restore_data.url.replace(/#.*/, "")) {
if (hasExpectedURL(aEvent.originalTarget, this.__SS_restore_data.url)) {
var content = aEvent.originalTarget.defaultView;
if (this.currentURI.spec == "about:config") {
// unwrap the document for about:config because otherwise the properties

Просмотреть файл

@ -376,15 +376,8 @@ nsJAR::GetCertificatePrincipal(const char* aFilename, nsIPrincipal** aPrincipal)
return NS_ERROR_NULL_POINTER;
*aPrincipal = nsnull;
//-- Get the signature verifier service
nsresult rv;
nsCOMPtr<nsISignatureVerifier> verifier =
do_GetService(SIGNATURE_VERIFIER_CONTRACTID, &rv);
if (NS_FAILED(rv)) // No signature verifier available
return NS_OK;
//-- Parse the manifest
rv = ParseManifest(verifier);
nsresult rv = ParseManifest();
if (NS_FAILED(rv)) return rv;
if (mGlobalStatus == JAR_NO_MANIFEST)
return NS_OK;
@ -525,7 +518,7 @@ nsJAR::ReadLine(const char** src)
#define JAR_SF_HEADER (const char*)"Signature-Version: 1.0"
nsresult
nsJAR::ParseManifest(nsISignatureVerifier* verifier)
nsJAR::ParseManifest()
{
//-- Verification Step 1
if (mParsedManifest)
@ -612,6 +605,16 @@ nsJAR::ParseManifest(nsISignatureVerifier* verifier)
return NS_OK;
}
//-- Get the signature verifier service
nsCOMPtr<nsISignatureVerifier> verifier =
do_GetService(SIGNATURE_VERIFIER_CONTRACTID, &rv);
if (NS_FAILED(rv)) // No signature verifier available
{
mGlobalStatus = JAR_NO_MANIFEST;
mParsedManifest = PR_TRUE;
return NS_OK;
}
//-- Verify that the signature file is a valid signature of the SF file
PRInt32 verifyError;
rv = verifier->VerifySignature(sigBuffer, sigLen, manifestBuffer, manifestLen,

Просмотреть файл

@ -154,7 +154,7 @@ class nsJAR : public nsIZipReader, public nsIJAR
//-- Private functions
PRFileDesc* OpenFile();
nsresult ParseManifest(nsISignatureVerifier* verifier);
nsresult ParseManifest();
void ReportError(const char* aFilename, PRInt16 errorCode);
nsresult LoadEntry(const char* aFilename, char** aBuf,
PRUint32* aBufLen = nsnull);