perform full same origin check on translator for getTranslatorObject(), rather than checking equality of URIs
This commit is contained in:
parent
ee101b5bc0
commit
924c537473
1 changed files with 18 additions and 3 deletions
|
@ -265,10 +265,25 @@ Zotero.Translate.Sandbox = {
|
||||||
};
|
};
|
||||||
safeTranslator.getTranslatorObject = function() {
|
safeTranslator.getTranslatorObject = function() {
|
||||||
translation._loadTranslator(translation.translator[0]);
|
translation._loadTranslator(translation.translator[0]);
|
||||||
if(translate._sandboxLocation != translation._sandboxLocation) {
|
|
||||||
throw "Translate: getTranslatorObject() may not be called from web or search "+
|
if(this.isFx) {
|
||||||
"translators to web or search translators with different URIs.";
|
// do same origin check
|
||||||
|
var secMan = Components.classes["@mozilla.org/scriptsecuritymanager;1"]
|
||||||
|
.getService(Components.interfaces.nsIScriptSecurityManager);
|
||||||
|
var ioService = Components.classes["@mozilla.org/network/io-service;1"]
|
||||||
|
.getService(Components.interfaces.nsIIOService);
|
||||||
|
|
||||||
|
var outerSandboxURI = ioService.newURI(typeof translate._sandboxLocation === "object" ?
|
||||||
|
translate._sandboxLocation.location : translate._sandboxLocation, null, null);
|
||||||
|
var innerSandboxURI = ioService.newURI(typeof translation._sandboxLocation === "object" ?
|
||||||
|
translation._sandboxLocation.location : translation._sandboxLocation, null, null);
|
||||||
|
|
||||||
|
if(!secMan.checkSameOriginURI(outerSandboxURI, innerSandboxURI, false)) {
|
||||||
|
throw "Translate: getTranslatorObject() may not be called from web or search "+
|
||||||
|
"translators to web or search translators from different origins.";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
translation._prepareTranslation();
|
translation._prepareTranslation();
|
||||||
setDefaultHandlers(translate, translation);
|
setDefaultHandlers(translate, translation);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue