Bug 479485 - Invalid port numbers cause default port to be used, should fail to load, r=bz

This commit is contained in:
Honza Bambas 2009-08-26 20:08:28 +02:00
parent be3553868b
commit 4ce6f49811
2 changed files with 30 additions and 1 deletions

View File

@ -617,7 +617,7 @@ nsAuthURLParser::ParseServerInfo(const char *serverinfo, PRInt32 serverinfoLen,
PRInt32 err;
*port = buf.ToInteger(&err);
if (NS_FAILED(err))
*port = -1;
return NS_ERROR_MALFORMED_URI;
}
}
else {

View File

@ -0,0 +1,29 @@
const Cc = Components.classes;
const Ci = Components.interfaces;
const Cr = Components.results;
function run_test() {
var ios = Cc["@mozilla.org/network/io-service;1"].
getService(Ci.nsIIOService);
var success = false;
try {
var newURI = ios.newURI("http://foo.com:invalid", null, null);
}
catch (e) {
success = e.result == Cr.NS_ERROR_MALFORMED_URI;
}
if (!success)
do_throw("We didn't throw NS_ERROR_MALFORMED_URI when creating a new URI with :invalid as a port");
success = false;
newURI = ios.newURI("http://foo.com", null, null);
try {
newURI.spec = "http://foo.com:invalid";
}
catch (e) {
success = e.result == Cr.NS_ERROR_MALFORMED_URI;
}
if (!success)
do_throw("We didn't throw NS_ERROR_MALFORMED_URI when setting a spec of a URI with :invalid as a port");
}