mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-25 19:25:43 +00:00
Skip over junky url's
This commit is contained in:
parent
76ac8992ec
commit
8f2d334714
@ -295,9 +295,33 @@ EndsWith(const nsString& aDomain, const char* aHost, PRInt32 aHostLen)
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
static PRBool
|
||||
StartsWith(const nsString& s1, const char* s2)
|
||||
{
|
||||
PRInt32 s1len = s1.Length();
|
||||
PRInt32 s2len = strlen(s2);
|
||||
if (s1len < s2len) {
|
||||
return PR_FALSE;
|
||||
}
|
||||
const PRUnichar* uc = s1.GetUnicode();
|
||||
const PRUnichar* end = uc + s2len;
|
||||
while (uc < end) {
|
||||
unsigned char uch = (unsigned char) ((*uc++) & 0xff);
|
||||
unsigned char ch = (unsigned char) ((*s2++) & 0xff);
|
||||
if (kLowerLookup[uch] != kLowerLookup[ch]) {
|
||||
return PR_FALSE;
|
||||
}
|
||||
}
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsWebCrawler::OkToLoad(const nsString& aURLSpec)
|
||||
{
|
||||
if (!StartsWith(aURLSpec, "http:") && !StartsWith(aURLSpec, "ftp:")) {
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
PRBool ok = PR_TRUE;
|
||||
nsIURL* url;
|
||||
nsresult rv = NS_NewURL(&url, aURLSpec);
|
||||
|
Loading…
Reference in New Issue
Block a user