mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-03 10:33:33 +00:00
Bug 585244: Don't attempt to prefetch invalid hostnames from content processes. r=dougt
This commit is contained in:
parent
9e76a00f6a
commit
c246dc25c2
@ -47,6 +47,7 @@
|
||||
#include "nsString.h"
|
||||
|
||||
#include "nsNetUtil.h"
|
||||
#include "nsURLHelper.h"
|
||||
|
||||
#include "nsIDNSListener.h"
|
||||
#include "nsIWebProgressListener.h"
|
||||
@ -64,6 +65,7 @@
|
||||
#include "mozilla/dom/Link.h"
|
||||
|
||||
using namespace mozilla::dom;
|
||||
using namespace mozilla::net;
|
||||
|
||||
static NS_DEFINE_CID(kDNSServiceCID, NS_DNSSERVICE_CID);
|
||||
PRBool sDisablePrefetchHTTPSPref;
|
||||
@ -107,8 +109,8 @@ nsHTMLDNSPrefetch::Initialize()
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
#ifdef MOZ_IPC
|
||||
if (mozilla::net::IsNeckoChild())
|
||||
mozilla::net::NeckoChild::InitNeckoChild();
|
||||
if (IsNeckoChild())
|
||||
NeckoChild::InitNeckoChild();
|
||||
#endif
|
||||
|
||||
sInitialized = PR_TRUE;
|
||||
@ -141,7 +143,7 @@ nsresult
|
||||
nsHTMLDNSPrefetch::Prefetch(Link *aElement, PRUint16 flags)
|
||||
{
|
||||
#ifdef MOZ_IPC
|
||||
if (mozilla::net::IsNeckoChild()) {
|
||||
if (IsNeckoChild()) {
|
||||
// Instead of transporting the Link object to the other process
|
||||
// we are using the hostname based function here, too. Compared to the
|
||||
// IPC the performance hit should be negligible.
|
||||
@ -181,8 +183,13 @@ nsresult
|
||||
nsHTMLDNSPrefetch::Prefetch(nsAString &hostname, PRUint16 flags)
|
||||
{
|
||||
#ifdef MOZ_IPC
|
||||
if (mozilla::net::IsNeckoChild()) {
|
||||
mozilla::net::gNeckoChild->SendHTMLDNSPrefetch(nsAutoString(hostname), flags);
|
||||
if (IsNeckoChild()) {
|
||||
// We need to check IsEmpty() because net_IsValidHostName()
|
||||
// considers empty strings to be valid hostnames
|
||||
if (!hostname.IsEmpty() &&
|
||||
net_IsValidHostName(NS_ConvertUTF16toUTF8(hostname))) {
|
||||
gNeckoChild->SendHTMLDNSPrefetch(nsAutoString(hostname), flags);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user