зеркало из https://github.com/mozilla/pjs.git
Bug 394525: don't try to malware check uris with no hostname. r=tony
This commit is contained in:
Родитель
00955ae01f
Коммит
f5dd3c1dc4
|
@ -2241,8 +2241,15 @@ nsUrlClassifierDBService::Classify(nsIURI *uri,
|
||||||
new nsUrlClassifierClassifyCallback(c);
|
new nsUrlClassifierClassifyCallback(c);
|
||||||
if (!callback) return NS_ERROR_OUT_OF_MEMORY;
|
if (!callback) return NS_ERROR_OUT_OF_MEMORY;
|
||||||
|
|
||||||
|
nsresult rv = LookupURI(uri, callback, PR_TRUE);
|
||||||
|
if (rv == NS_ERROR_MALFORMED_URI) {
|
||||||
|
// The URI had no hostname, don't try to classify it.
|
||||||
|
*result = PR_FALSE;
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
*result = PR_TRUE;
|
*result = PR_TRUE;
|
||||||
return LookupURI(uri, callback, PR_TRUE);
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
|
|
|
@ -130,6 +130,10 @@ nsUrlClassifierUtils::GetKeyForURI(nsIURI * uri, nsACString & _retval)
|
||||||
nsCAutoString host;
|
nsCAutoString host;
|
||||||
innerURI->GetAsciiHost(host);
|
innerURI->GetAsciiHost(host);
|
||||||
|
|
||||||
|
if (host.IsEmpty()) {
|
||||||
|
return NS_ERROR_MALFORMED_URI;
|
||||||
|
}
|
||||||
|
|
||||||
nsresult rv = CanonicalizeHostname(host, _retval);
|
nsresult rv = CanonicalizeHostname(host, _retval);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
|
|
|
@ -55,6 +55,22 @@ function testFailure(arg) {
|
||||||
do_throw(arg);
|
do_throw(arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function checkNoHost()
|
||||||
|
{
|
||||||
|
// Looking up a no-host uri such as a data: uri should throw an exception.
|
||||||
|
var exception;
|
||||||
|
try {
|
||||||
|
dbservice.lookup("data:text/html,<b>test</b>");
|
||||||
|
|
||||||
|
exception = false;
|
||||||
|
} catch(e) {
|
||||||
|
exception = true;
|
||||||
|
}
|
||||||
|
do_check_true(exception);
|
||||||
|
|
||||||
|
do_test_finished();
|
||||||
|
}
|
||||||
|
|
||||||
function tablesCallback(tables)
|
function tablesCallback(tables)
|
||||||
{
|
{
|
||||||
var parts = tables.split("\n");
|
var parts = tables.split("\n");
|
||||||
|
@ -63,7 +79,8 @@ function tablesCallback(tables)
|
||||||
// after the trailing newline, which will sort first
|
// after the trailing newline, which will sort first
|
||||||
do_check_eq(parts.join("\n"),
|
do_check_eq(parts.join("\n"),
|
||||||
"\ntesting-malware-simple;a:1\ntesting-phish-simple;a:2:s:3");
|
"\ntesting-malware-simple;a:1\ntesting-phish-simple;a:2:s:3");
|
||||||
do_test_finished();
|
|
||||||
|
checkNoHost();
|
||||||
}
|
}
|
||||||
|
|
||||||
function checkChunks()
|
function checkChunks()
|
||||||
|
|
Загрузка…
Ссылка в новой задаче