diff --git a/mozilla/browser/base/content/browser.js b/mozilla/browser/base/content/browser.js index 3d89800f41a..1db8ee862d9 100644 --- a/mozilla/browser/base/content/browser.js +++ b/mozilla/browser/base/content/browser.js @@ -657,7 +657,8 @@ function BrowserStartup() # only load url passed in when we're not page cycling if (uriToLoad && !gIsLoadingBlank) { if (window.arguments.length >= 3) - loadURI(uriToLoad, window.arguments[2], window.arguments[3] || null); + loadURI(uriToLoad, window.arguments[2], window.arguments[3] || null, + window.arguments[4] || false); else loadOneOrMoreURIs(uriToLoad); } @@ -1711,7 +1712,7 @@ function openLocationCallback() function BrowserOpenTab() { - gBrowser.loadOneTab("about:blank", null, null, null, false); + gBrowser.loadOneTab("about:blank", null, null, null, false, false); if (gURLBar) setTimeout(function() { gURLBar.focus(); }, 0); } @@ -1732,9 +1733,9 @@ function delayedOpenWindow(chrome, flags, href, postData) /* Required because the tab needs time to set up its content viewers and get the load of the URI kicked off before becoming the active content area. */ -function delayedOpenTab(aUrl, aReferrer, aCharset, aPostData) +function delayedOpenTab(aUrl, aReferrer, aCharset, aPostData, aAllowThirdPartyFixup) { - gBrowser.loadOneTab(aUrl, aReferrer, aCharset, aPostData, false); + gBrowser.loadOneTab(aUrl, aReferrer, aCharset, aPostData, false, aAllowThirdPartyFixup); } function BrowserOpenFileWindow() @@ -1803,12 +1804,16 @@ function BrowserCloseWindow() closeWindow(true); } -function loadURI(uri, referrer, postData) +function loadURI(uri, referrer, postData, allowThirdPartyFixup) { try { if (postData === undefined) postData = null; - getWebNavigation().loadURI(uri, nsIWebNavigation.LOAD_FLAGS_NONE, referrer, postData, null); + var flags = nsIWebNavigation.LOAD_FLAGS_NONE; + if (allowThirdPartyFixup) { + flags = nsIWebNavigation.LOAD_FLAGS_ALLOW_THIRD_PARTY_FIXUP; + } + getWebNavigation().loadURI(uri, flags, referrer, postData, null); } catch (e) { } } @@ -1821,13 +1826,14 @@ function BrowserLoadURL(aTriggeringEvent, aPostData) aTriggeringEvent.altKey) { handleURLBarRevert(); content.focus(); - gBrowser.loadOneTab(url, null, null, aPostData, false); + gBrowser.loadOneTab(url, null, null, aPostData, false, + true /* allow third party fixup */); gURLBar.value = url; aTriggeringEvent.preventDefault(); aTriggeringEvent.stopPropagation(); } else - loadURI(url, null, aPostData); + loadURI(url, null, aPostData, true /* allow third party fixup */); content.focus(); } @@ -2667,7 +2673,8 @@ var newTabButtonObserver = { var url = getShortcutOrURI(draggedText, postData); if (url) { getBrowser().dragDropSecurityCheck(aEvent, aDragSession, url); - openNewTabWith(url, null, postData.value, aEvent); + // allow third-party services to fixup this URL + openNewTabWith(url, null, postData.value, aEvent, true); } }, getSupportedFlavours: function () @@ -2702,7 +2709,8 @@ var newWindowButtonObserver = { var url = getShortcutOrURI(draggedText, postData); if (url) { getBrowser().dragDropSecurityCheck(aEvent, aDragSession, url); - openNewWindowWith(url, null, postData.value); + // allow third-party services to fixup this URL + openNewWindowWith(url, null, postData.value, true); } }, getSupportedFlavours: function () @@ -2742,7 +2750,7 @@ var goButtonObserver = { .getService(Components.interfaces.nsIScriptSecurityManager); const nsIScriptSecMan = Components.interfaces.nsIScriptSecurityManager; secMan.checkLoadURI(gBrowser.currentURI, uri, nsIScriptSecMan.DISALLOW_SCRIPT_OR_DATA); - loadURI(uri.spec, null, postData.value); + loadURI(uri.spec, null, postData.value, true); } catch (ex) {} }, getSupportedFlavours: function () @@ -2823,7 +2831,7 @@ const BrowserSearch = { var ss = Cc["@mozilla.org/browser/search-service;1"]. getService(Ci.nsIBrowserSearchService); var searchForm = ss.defaultEngine.searchForm; - loadURI(searchForm, null, null); + loadURI(searchForm, null, null, false); } }, @@ -2854,9 +2862,9 @@ const BrowserSearch = { if (useNewTab) { getBrowser().loadOneTab(submission.uri.spec, null, null, - submission.postData); + submission.postData, false); } else - loadURI(submission.uri.spec, null, submission.postData); + loadURI(submission.uri.spec, null, submission.postData, false); }, /** @@ -3763,7 +3771,7 @@ nsBrowserAccess.prototype = break; case nsCI.nsIBrowserDOMWindow.OPEN_NEWTAB : var loadInBackground = gPrefService.getBoolPref("browser.tabs.loadDivertedInBackground"); - var newTab = gBrowser.loadOneTab("about:blank", null, null, null, loadInBackground); + var newTab = gBrowser.loadOneTab("about:blank", null, null, null, loadInBackground, false); newWindow = gBrowser.getBrowserForTab(newTab).docShell .QueryInterface(nsCI.nsIInterfaceRequestor) .getInterface(nsCI.nsIDOMWindow); @@ -4560,15 +4568,15 @@ nsContextMenu.prototype = { // Open linked-to URL in a new window. openLink : function () { - openNewWindowWith(this.linkURL, this.docURL, null); + openNewWindowWith(this.linkURL, this.docURL, null, false); }, // Open linked-to URL in a new tab. openLinkInTab : function () { - openNewTabWith(this.linkURL, this.docURL, null, null); + openNewTabWith(this.linkURL, this.docURL, null, null, false); }, // Open frame in a new tab. openFrameInTab : function () { - openNewTabWith(this.target.ownerDocument.location.href, null, null, null); + openNewTabWith(this.target.ownerDocument.location.href, null, null, null, false); }, // Reload clicked-in frame. reloadFrame : function () { @@ -4576,11 +4584,11 @@ nsContextMenu.prototype = { }, // Open clicked-in frame in its own window. openFrame : function () { - openNewWindowWith(this.target.ownerDocument.location.href, null, null); + openNewWindowWith(this.target.ownerDocument.location.href, null, null, false); }, // Open clicked-in frame in the same window. showOnlyThisFrame : function () { - window.loadURI(this.target.ownerDocument.location.href, null, null); + window.loadURI(this.target.ownerDocument.location.href, null, null, false); }, // View Partial Source viewPartialSource : function ( context ) { @@ -5142,7 +5150,7 @@ function asyncOpenWebPanel(event) var url = getShortcutOrURI(wrapper.href, postData); if (!url) return true; - loadURI(url, null, postData.value); + loadURI(url, null, postData.value, false); event.preventDefault(); return false; } @@ -5231,13 +5239,13 @@ function handleLinkClick(event, href, linkNode) #else if (event.ctrlKey) { #endif - openNewTabWith(href, docURL, null, event); + openNewTabWith(href, docURL, null, event, false); event.stopPropagation(); return true; } // if left button clicked if (event.shiftKey) { - openNewWindowWith(href, docURL, null); + openNewWindowWith(href, docURL, null, false); event.stopPropagation(); return true; } @@ -5258,9 +5266,9 @@ function handleLinkClick(event, href, linkNode) tab = true; } if (tab) - openNewTabWith(href, docURL, null, event); + openNewTabWith(href, docURL, null, event, false); else - openNewWindowWith(href, docURL, null); + openNewWindowWith(href, docURL, null, false); event.stopPropagation(); return true; } @@ -5328,7 +5336,7 @@ var contentAreaDNDObserver = { case "navigator:browser": var postData = { }; var uri = getShortcutOrURI(url, postData); - loadURI(uri, null, postData.value); + loadURI(uri, null, postData.value, false); break; case "navigator:view-source": viewSource(url); diff --git a/mozilla/browser/base/content/openLocation.js b/mozilla/browser/base/content/openLocation.js index 941bc85aba4..14631e0feaa 100644 --- a/mozilla/browser/base/content/openLocation.js +++ b/mozilla/browser/base/content/openLocation.js @@ -101,18 +101,21 @@ function open() url = dialog.input.value; try { + // Whichever target we use for the load, we allow third-party services to + // fixup the URI switch (dialog.openWhereList.value) { case "0": - browser.loadURI(url, null, postData.value); + browser.loadURI(url, null, postData.value, true); break; case "1": - window.opener.delayedOpenWindow(getBrowserURL(), "all,dialog=no", url, postData.value); + window.opener.delayedOpenWindow(getBrowserURL(), "all,dialog=no", + url, postData.value, null, null, true); break; case "3": if (browser.getBrowser && browser.getBrowser().localName == "tabbrowser") - browser.delayedOpenTab(url, null, null, postData.value); + browser.delayedOpenTab(url, null, null, postData.value, true); else - browser.loadURI(url, null, postData.value); // Just do a normal load. + browser.loadURI(url, null, postData.value, true); // Just do a normal load. break; } } diff --git a/mozilla/browser/base/content/utilityOverlay.js b/mozilla/browser/base/content/utilityOverlay.js index 0b9bda4c262..9b6a226d92f 100644 --- a/mozilla/browser/base/content/utilityOverlay.js +++ b/mozilla/browser/base/content/utilityOverlay.js @@ -120,7 +120,7 @@ function getBoolPref ( prefname, def ) function openUILink( url, e, ignoreButton, ignoreAlt ) { var where = whereToOpenLink(e, ignoreButton, ignoreAlt); - openUILinkIn(url, where); + openUILinkIn(url, where, false); } @@ -193,8 +193,12 @@ function whereToOpenLink( e, ignoreButton, ignoreAlt ) * "tabshifted" same as "tab" but in background if default is to select new tabs, and vice versa * "window" new window * "save" save to disk (with no filename hint!) + * + * allowThirdPartyFixup controls whether third party services such as Google's + * I Feel Lucky are allowed to interpret this URL. This parameter may be + * undefined, which is treated as false. */ -function openUILinkIn( url, where ) +function openUILinkIn( url, where, allowThirdPartyFixup ) { if (!where) return; @@ -230,7 +234,8 @@ function openUILinkIn( url, where ) case "tabshifted": case "tab": var loadInBackground = getBoolPref("browser.tabs.loadBookmarksInBackground", false); - browser.loadOneTab(url, null, null, null, loadInBackground); + browser.loadOneTab(url, null, null, null, loadInBackground, + allowThirdPartyFixup || false); break; } } diff --git a/mozilla/browser/components/bookmarks/content/bookmarks.js b/mozilla/browser/components/bookmarks/content/bookmarks.js index de8a9b72b7a..ce3d313512b 100644 --- a/mozilla/browser/components/bookmarks/content/bookmarks.js +++ b/mozilla/browser/components/bookmarks/content/bookmarks.js @@ -686,7 +686,7 @@ var BookmarksCommand = { if (url == "") return; - openUILinkIn(url, aTargetBrowser); + openUILinkIn(url, aTargetBrowser, false); }, openGroupBookmark: function (aURI, aTargetBrowser) diff --git a/mozilla/browser/components/places/content/controller.js b/mozilla/browser/components/places/content/controller.js index d16586adf92..780906a9cfc 100755 --- a/mozilla/browser/components/places/content/controller.js +++ b/mozilla/browser/components/places/content/controller.js @@ -1282,7 +1282,7 @@ var PlacesController = { if (node) { var browser = this._getBrowserWindow(); if (browser) - browser.openNewWindowWith(node.uri, null, null); + browser.openNewWindowWith(node.uri, null, null, false); else this._openBrowserWith(node.uri); } @@ -1296,7 +1296,7 @@ var PlacesController = { if (node) { var browser = this._getBrowserWindow(); if (browser) - browser.loadURI(node.uri, null, null); + browser.loadURI(node.uri, null, null, false); else this._openBrowserWith(node.uri); } diff --git a/mozilla/browser/components/search/content/search.xml b/mozilla/browser/components/search/content/search.xml index 959825aefd6..e4d9b3dc401 100644 --- a/mozilla/browser/components/search/content/search.xml +++ b/mozilla/browser/components/search/content/search.xml @@ -226,7 +226,7 @@ /* openDialog("chrome://browser/content/search/edit-engines.xul", "", "modal,centerscreen"); */ var regionBundle = document.getElementById("bundle_browser_region"); - loadURI(regionBundle.getString("searchEnginesURL"), null, null); + loadURI(regionBundle.getString("searchEnginesURL"), null, null, false); } else { this.currentEngine = aEvent.target.engine; this.focus(); @@ -270,11 +270,11 @@ if (aInNewTab) { content.focus(); - getBrowser().loadOneTab(url, null, null, postData.value, false); + getBrowser().loadOneTab(url, null, null, postData.value, false, false); if (gURLBar) gURLBar.value = url; } else - loadURI(url, null, postData.value); + loadURI(url, null, postData.value, false); content.focus(); ]]> diff --git a/mozilla/calendar/resources/content/pref/pref.xul b/mozilla/calendar/resources/content/pref/pref.xul index ac66cde95c3..48288bd1e1a 100644 --- a/mozilla/calendar/resources/content/pref/pref.xul +++ b/mozilla/calendar/resources/content/pref/pref.xul @@ -77,7 +77,7 @@ var url = node.getAttribute("link"); if (url != "") - window.opener.openNewWindowWith(url, null, false); + window.opener.openNewWindowWith(url, null, false, false); } ]]> diff --git a/mozilla/docshell/base/nsDocShell.cpp b/mozilla/docshell/base/nsDocShell.cpp index e5ec5743404..80093e2b150 100644 --- a/mozilla/docshell/base/nsDocShell.cpp +++ b/mozilla/docshell/base/nsDocShell.cpp @@ -259,6 +259,7 @@ nsDocShell::nsDocShell(): mUseErrorPages(PR_FALSE), mObserveErrorPages(PR_TRUE), mAllowAuth(PR_TRUE), + mAllowKeywordFixup(PR_FALSE), mFiredUnloadEvent(PR_FALSE), mEODForCurrentDocument(PR_FALSE), mURIResultedInDocument(PR_FALSE), @@ -801,6 +802,9 @@ nsDocShell::LoadURI(nsIURI * aURI, if (!sendReferrer) flags |= INTERNAL_LOAD_FLAGS_DONT_SEND_REFERRER; + + if (aLoadFlags & LOAD_FLAGS_ALLOW_THIRD_PARTY_FIXUP) + flags |= INTERNAL_LOAD_FLAGS_ALLOW_THIRD_PARTY_FIXUP; rv = InternalLoad(aURI, referrer, @@ -828,6 +832,8 @@ nsDocShell::LoadStream(nsIInputStream *aStream, nsIURI * aURI, { NS_ENSURE_ARG(aStream); + mAllowKeywordFixup = PR_FALSE; + // if the caller doesn't pass in a URI we need to create a dummy URI. necko // currently requires a URI in various places during the load. Some consumers // do as well. @@ -2793,8 +2799,11 @@ nsDocShell::LoadURI(const PRUnichar * aURI, rv = NS_NewURI(getter_AddRefs(uri), uriString); } else { // Call the fixup object - rv = sURIFixup->CreateFixupURI(NS_ConvertUTF16toUTF8(aURI), - nsIURIFixup::FIXUP_FLAG_ALLOW_KEYWORD_LOOKUP, + PRUint32 fixupFlags = 0; + if (aLoadFlags & LOAD_FLAGS_ALLOW_THIRD_PARTY_FIXUP) { + fixupFlags |= nsIURIFixup::FIXUP_FLAG_ALLOW_KEYWORD_LOOKUP; + } + rv = sURIFixup->CreateFixupURI(NS_ConvertUTF16toUTF8(aURI), fixupFlags, getter_AddRefs(uri)); } @@ -2815,8 +2824,9 @@ nsDocShell::LoadURI(const PRUnichar * aURI, loadInfo->SetReferrer(aReferringURI); loadInfo->SetHeadersStream(aHeaderStream); - rv = LoadURI(uri, loadInfo, 0, PR_TRUE); - + rv = LoadURI(uri, loadInfo, + aLoadFlags & LOAD_FLAGS_ALLOW_THIRD_PARTY_FIXUP, PR_TRUE); + return rv; } @@ -6361,6 +6371,8 @@ nsDocShell::InternalLoad(nsIURI * aURI, return rv; } + mAllowKeywordFixup = + (aFlags & INTERNAL_LOAD_FLAGS_ALLOW_THIRD_PARTY_FIXUP) != 0; mURIResultedInDocument = PR_FALSE; // reset the clock... // diff --git a/mozilla/docshell/base/nsDocShell.h b/mozilla/docshell/base/nsDocShell.h index 23afe758f5d..f85bade539d 100644 --- a/mozilla/docshell/base/nsDocShell.h +++ b/mozilla/docshell/base/nsDocShell.h @@ -477,6 +477,7 @@ protected: PRPackedBool mUseErrorPages; PRPackedBool mObserveErrorPages; PRPackedBool mAllowAuth; + PRPackedBool mAllowKeywordFixup; PRPackedBool mFiredUnloadEvent; diff --git a/mozilla/docshell/base/nsIDocShell.idl b/mozilla/docshell/base/nsIDocShell.idl index 02e2b5c94f0..d6a6e08cc0f 100644 --- a/mozilla/docshell/base/nsIDocShell.idl +++ b/mozilla/docshell/base/nsIDocShell.idl @@ -115,9 +115,10 @@ interface nsIDocShell : nsISupports in ACString aContentCharset, in nsIDocShellLoadInfo aLoadInfo); - const long INTERNAL_LOAD_FLAGS_NONE = 0x0; - const long INTERNAL_LOAD_FLAGS_INHERIT_OWNER = 0x1; - const long INTERNAL_LOAD_FLAGS_DONT_SEND_REFERRER = 0x2; + const long INTERNAL_LOAD_FLAGS_NONE = 0x0; + const long INTERNAL_LOAD_FLAGS_INHERIT_OWNER = 0x1; + const long INTERNAL_LOAD_FLAGS_DONT_SEND_REFERRER = 0x2; + const long INTERNAL_LOAD_FLAGS_ALLOW_THIRD_PARTY_FIXUP = 0x4; /** * Loads the given URI. This method is identical to loadURI(...) except diff --git a/mozilla/docshell/base/nsIWebNavigation.idl b/mozilla/docshell/base/nsIWebNavigation.idl index 60eee40646a..823a9b877b9 100644 --- a/mozilla/docshell/base/nsIWebNavigation.idl +++ b/mozilla/docshell/base/nsIWebNavigation.idl @@ -175,6 +175,13 @@ interface nsIWebNavigation : nsISupports * A hint this load was prompted by an external program: take care! */ const unsigned long LOAD_FLAGS_FROM_EXTERNAL = 0x1000; + + /** + * This flag specifies that the URI may be submitted to a third-party + * server for correction. This should only be applied to non-sensitive + * URIs entered by users. + */ + const unsigned long LOAD_FLAGS_ALLOW_THIRD_PARTY_FIXUP = 0x2000; /** * Loads a given URI. This will give priority to loading the requested URI diff --git a/mozilla/docshell/base/nsWebShell.cpp b/mozilla/docshell/base/nsWebShell.cpp index 90e019ff7f9..5554df324ae 100644 --- a/mozilla/docshell/base/nsWebShell.cpp +++ b/mozilla/docshell/base/nsWebShell.cpp @@ -958,7 +958,7 @@ nsresult nsWebShell::EndPageLoad(nsIWebProgress *aProgress, // // First try keyword fixup // - if (aStatus == NS_ERROR_UNKNOWN_HOST) + if (aStatus == NS_ERROR_UNKNOWN_HOST && mAllowKeywordFixup) { PRBool keywordsEnabled = PR_FALSE; diff --git a/mozilla/toolkit/content/contentAreaUtils.js b/mozilla/toolkit/content/contentAreaUtils.js index e689e9b0a18..0636f3e05fb 100644 --- a/mozilla/toolkit/content/contentAreaUtils.js +++ b/mozilla/toolkit/content/contentAreaUtils.js @@ -49,8 +49,11 @@ * If null, there will be no referrer header and no security check. * @param postData Form POST data, or null. * @param event The triggering event (for the purpose of determining whether to open in the background), or null + * @param allowThirdPartyFixup if true, then we allow the URL text to be sent to third party + * services (e.g., Google's I Feel Lucky) for interpretation. This parameter may be undefined in + * which case it is treated as false. */ -function openNewTabWith(href, sourceURL, postData, event) +function openNewTabWith(href, sourceURL, postData, event, allowThirdPartyFixup) { if (sourceURL) urlSecurityCheck(href, sourceURL); @@ -82,10 +85,11 @@ function openNewTabWith(href, sourceURL, postData, event) var referrerURI = sourceURL ? makeURI(sourceURL) : null; - browser.loadOneTab(href, referrerURI, originCharset, postData, loadInBackground); + browser.loadOneTab(href, referrerURI, originCharset, postData, loadInBackground, + allowThirdPartyFixup || false); } -function openNewWindowWith(href, sourceURL, postData) +function openNewWindowWith(href, sourceURL, postData, allowThirdPartyFixup) { if (sourceURL) urlSecurityCheck(href, sourceURL); @@ -100,7 +104,8 @@ function openNewWindowWith(href, sourceURL, postData) var referrerURI = sourceURL ? makeURI(sourceURL) : null; - window.openDialog(getBrowserURL(), "_blank", "chrome,all,dialog=no", href, charsetArg, referrerURI, postData); + window.openDialog(getBrowserURL(), "_blank", "chrome,all,dialog=no", + href, charsetArg, referrerURI, postData, allowThirdPartyFixup); } /** diff --git a/mozilla/toolkit/content/globalOverlay.js b/mozilla/toolkit/content/globalOverlay.js index 67cbe7c5378..5e847efdddb 100644 --- a/mozilla/toolkit/content/globalOverlay.js +++ b/mozilla/toolkit/content/globalOverlay.js @@ -225,7 +225,7 @@ function visitLink(aEvent) { node = node.parentNode; var url = node.getAttribute("link"); if (url != "") - top.opener.openNewWindowWith(url, null, false); + top.opener.openNewWindowWith(url, null, false, false); } function isValidLeftClick(aEvent, aName) diff --git a/mozilla/toolkit/content/widgets/tabbrowser.xml b/mozilla/toolkit/content/widgets/tabbrowser.xml index 7c09850387f..d03568e80cb 100644 --- a/mozilla/toolkit/content/widgets/tabbrowser.xml +++ b/mozilla/toolkit/content/widgets/tabbrowser.xml @@ -1038,10 +1038,12 @@ + +