зеркало из https://github.com/mozilla/gecko-dev.git
Bug 315166: make the text-link binding be more careful about which protocols it allows, r=mconnor
This commit is contained in:
Родитель
3ceefe127d
Коммит
bd9182dfa8
|
@ -333,9 +333,11 @@
|
|||
|
||||
<method name="showHistoryPopup">
|
||||
<body><![CDATA[
|
||||
#ifndef MOZILLA_1_8_BRANCH
|
||||
// This is an autocomplete widget, but we want the rollup event
|
||||
// to be consumed, as if we were a menulist.
|
||||
this.popup.popupBoxObject.setConsumeRollupEvent(Components.interfaces.nsIPopupBoxObject.ROLLUP_CONSUME);
|
||||
#endif
|
||||
|
||||
this.maxRows = 14;
|
||||
this.attachController();
|
||||
|
@ -726,7 +728,16 @@
|
|||
controller.handleEnter();
|
||||
]]></body>
|
||||
</method>
|
||||
|
||||
#ifdef MOZILLA_1_8_BRANCH
|
||||
|
||||
<method name="clearOpenProperty">
|
||||
<parameter name="aPopupNode"/>
|
||||
<body><![CDATA[
|
||||
aPopupNode.mPopupOpen = false;
|
||||
]]></body>
|
||||
</method>
|
||||
#endif
|
||||
|
||||
</implementation>
|
||||
|
||||
<handlers>
|
||||
|
@ -735,7 +746,11 @@
|
|||
</handler>
|
||||
|
||||
<handler event="popuphiding">
|
||||
#ifdef MOZILLA_1_8_BRANCH
|
||||
setTimeout(this.clearOpenProperty, 0, this);
|
||||
#else
|
||||
this.mPopupOpen = false;
|
||||
#endif
|
||||
this.mInput.maxRows = 6;
|
||||
</handler>
|
||||
</handlers>
|
||||
|
@ -819,7 +834,13 @@
|
|||
<method name="showPopup">
|
||||
<body><![CDATA[
|
||||
var textbox = document.getBindingParent(this);
|
||||
#ifdef MOZILLA_1_8_BRANCH
|
||||
if (!textbox.popup.mPopupOpen) {
|
||||
textbox.showHistoryPopup();
|
||||
}
|
||||
#else
|
||||
textbox.showHistoryPopup();
|
||||
#endif
|
||||
]]></body>
|
||||
</method>
|
||||
</implementation>
|
||||
|
|
|
@ -291,44 +291,66 @@
|
|||
</property>
|
||||
<property name="href" onget="return this.getAttribute('href');"
|
||||
onset="this.setAttribute('href', val); return val;" />
|
||||
<method name="open">
|
||||
<method name="open">
|
||||
<parameter name="aEvent"/>
|
||||
<body>
|
||||
<![CDATA[
|
||||
if (this.disabled || aEvent.getPreventDefault())
|
||||
var href = this.href;
|
||||
if (!href || this.disabled || aEvent.getPreventDefault())
|
||||
return;
|
||||
var href = this.getAttribute('href');
|
||||
|
||||
if (href)
|
||||
{
|
||||
try {
|
||||
var uri = Components.classes["@mozilla.org/network/io-service;1"]
|
||||
.getService(Components.interfaces.nsIIOService)
|
||||
.newURI(href, null, null);
|
||||
|
||||
var protocolSvc = Components.classes["@mozilla.org/uriloader/external-protocol-service;1"]
|
||||
.getService(Components.interfaces.nsIExternalProtocolService);
|
||||
// if the scheme is not an exposed protocol, then opening this link should
|
||||
// be deferred to the system's external protocol handler
|
||||
if (!protocolSvc.isExposedProtocol(uri.scheme))
|
||||
{
|
||||
protocolSvc.loadUrl(uri);
|
||||
aEvent.preventDefault()
|
||||
return;
|
||||
}
|
||||
var uri = null;
|
||||
try {
|
||||
const nsISSM = Components.interfaces.nsIScriptSecurityManager;
|
||||
const secMan =
|
||||
Components.classes["@mozilla.org/scriptsecuritymanager;1"]
|
||||
.getService(nsISSM);
|
||||
|
||||
const ioService =
|
||||
Components.classes["@mozilla.org/network/io-service;1"]
|
||||
.getService(Components.interfaces.nsIIOService);
|
||||
|
||||
uri = ioService.newURI(href, null, null);
|
||||
var safeURI = ioService.newURI("about:blank", null, null);
|
||||
|
||||
try {
|
||||
secMan.checkLoadURI(safeURI, uri, nsISSM.DISALLOW_SCRIPT_OR_DATA)
|
||||
} catch (ex) {
|
||||
var msg = "Error: Cannot open a " + uri.scheme + ": link using \
|
||||
the text-link binding.";
|
||||
Components.utils.reportError(msg);
|
||||
return;
|
||||
}
|
||||
catch (ex) {}
|
||||
|
||||
// otherwise, fall back to opening the anchor directly
|
||||
var win = window;
|
||||
if (window instanceof Components.interfaces.nsIDOMChromeWindow) {
|
||||
while (win.opener && !win.opener.closed)
|
||||
win = win.opener;
|
||||
|
||||
const cID = "@mozilla.org/uriloader/external-protocol-service;1";
|
||||
const nsIEPS = Components.interfaces.nsIExternalProtocolService;
|
||||
var protocolSvc = Components.classes[contractID]
|
||||
.getService(nsIEPS);
|
||||
|
||||
// if the scheme is not an exposed protocol, then opening this link
|
||||
// should be deferred to the system's external protocol handler
|
||||
if (!protocolSvc.isExposedProtocol(uri.scheme)) {
|
||||
protocolSvc.loadUrl(uri);
|
||||
aEvent.preventDefault()
|
||||
return;
|
||||
}
|
||||
|
||||
} catch (ex) {}
|
||||
|
||||
// otherwise, fall back to opening the anchor directly
|
||||
var win = window;
|
||||
if (window instanceof Components.interfaces.nsIDOMChromeWindow) {
|
||||
while (win.opener && !win.opener.closed)
|
||||
win = win.opener;
|
||||
}
|
||||
|
||||
if (uri)
|
||||
win.open(uri.spec);
|
||||
else
|
||||
win.open(href);
|
||||
|
||||
aEvent.preventDefault();
|
||||
}
|
||||
aEvent.preventDefault();
|
||||
|
||||
]]>
|
||||
</body>
|
||||
</method>
|
||||
|
@ -336,7 +358,7 @@
|
|||
|
||||
<handlers>
|
||||
<handler event="click" phase="capturing" button="0" action="this.open(event)"/>
|
||||
<handler event="keypress" preventdefault="true" keycode="VK_ENTER" action="this.click()" />
|
||||
<handler event="keypress" preventdefault="true" keycode="VK_ENTER" action="this.click()" />
|
||||
<handler event="keypress" preventdefault="true" keycode="VK_RETURN" action="this.click()" />
|
||||
</handlers>
|
||||
</binding>
|
||||
|
|
Загрузка…
Ссылка в новой задаче