missed a case

This commit is contained in:
valeski%netscape.com 1999-11-02 04:22:12 +00:00
parent b7021722f9
commit 00924492ac
2 changed files with 60 additions and 56 deletions

View File

@ -2216,37 +2216,39 @@ nsWebShell::LoadURL(const PRUnichar *aURLSpec,
rv = NS_NewURI(getter_AddRefs(uri), keywordSpec, nsnull); rv = NS_NewURI(getter_AddRefs(uri), keywordSpec, nsnull);
} }
PRInt32 colon, fSlash = urlSpec.FindChar('/'); if (NS_FAILED(rv)) {
PRUnichar port; PRInt32 colon, fSlash = urlSpec.FindChar('/');
// if no scheme (protocol) is found, assume http. PRUnichar port;
if ( ((colon=urlSpec.FindChar(':')) == -1) // no colon at all // if no scheme (protocol) is found, assume http.
|| ( (fSlash > -1) && (colon > fSlash) ) // the only colon comes after the first slash if ( ((colon=urlSpec.FindChar(':')) == -1) // no colon at all
|| ( (colon < urlSpec.Length()-1) // the first char after the first colon is a digit (i.e. a port) || ( (fSlash > -1) && (colon > fSlash) ) // the only colon comes after the first slash
&& ((port=urlSpec.CharAt(colon+1)) <= '9') || ( (colon < urlSpec.Length()-1) // the first char after the first colon is a digit (i.e. a port)
&& (port > '0') )) { && ((port=urlSpec.CharAt(colon+1)) <= '9')
// find host name && (port > '0') )) {
PRInt32 hostPos = urlSpec.FindCharInSet("./:"); // find host name
if (hostPos == -1) { PRInt32 hostPos = urlSpec.FindCharInSet("./:");
hostPos = urlSpec.Length(); if (hostPos == -1) {
} hostPos = urlSpec.Length();
}
// extract host name // extract host name
nsAutoString hostSpec; nsAutoString hostSpec;
urlSpec.Left(hostSpec, hostPos); urlSpec.Left(hostSpec, hostPos);
// insert url spec corresponding to host name // insert url spec corresponding to host name
if (hostSpec.EqualsIgnoreCase("ftp")) { if (hostSpec.EqualsIgnoreCase("ftp")) {
urlSpec.Insert("ftp://", 0, 6); urlSpec.Insert("ftp://", 0, 6);
} else { } else {
urlSpec.Insert("http://", 0, 7); urlSpec.Insert("http://", 0, 7);
} }
} // end if colon } // end if colon
rv = NS_NewURI(getter_AddRefs(uri), urlSpec, nsnull); rv = NS_NewURI(getter_AddRefs(uri), urlSpec, nsnull);
nsAutoString url(aURLSpec); nsAutoString url(aURLSpec);
if (((url.Find("mailto:", PR_TRUE))<0) && (NS_FAILED(rv))) { if (((url.Find("mailto:", PR_TRUE))<0) && (NS_FAILED(rv))) {
// no dice, even more tricks? // no dice, even more tricks?
return rv; return rv;
}
} }
} }

View File

@ -2216,37 +2216,39 @@ nsWebShell::LoadURL(const PRUnichar *aURLSpec,
rv = NS_NewURI(getter_AddRefs(uri), keywordSpec, nsnull); rv = NS_NewURI(getter_AddRefs(uri), keywordSpec, nsnull);
} }
PRInt32 colon, fSlash = urlSpec.FindChar('/'); if (NS_FAILED(rv)) {
PRUnichar port; PRInt32 colon, fSlash = urlSpec.FindChar('/');
// if no scheme (protocol) is found, assume http. PRUnichar port;
if ( ((colon=urlSpec.FindChar(':')) == -1) // no colon at all // if no scheme (protocol) is found, assume http.
|| ( (fSlash > -1) && (colon > fSlash) ) // the only colon comes after the first slash if ( ((colon=urlSpec.FindChar(':')) == -1) // no colon at all
|| ( (colon < urlSpec.Length()-1) // the first char after the first colon is a digit (i.e. a port) || ( (fSlash > -1) && (colon > fSlash) ) // the only colon comes after the first slash
&& ((port=urlSpec.CharAt(colon+1)) <= '9') || ( (colon < urlSpec.Length()-1) // the first char after the first colon is a digit (i.e. a port)
&& (port > '0') )) { && ((port=urlSpec.CharAt(colon+1)) <= '9')
// find host name && (port > '0') )) {
PRInt32 hostPos = urlSpec.FindCharInSet("./:"); // find host name
if (hostPos == -1) { PRInt32 hostPos = urlSpec.FindCharInSet("./:");
hostPos = urlSpec.Length(); if (hostPos == -1) {
} hostPos = urlSpec.Length();
}
// extract host name // extract host name
nsAutoString hostSpec; nsAutoString hostSpec;
urlSpec.Left(hostSpec, hostPos); urlSpec.Left(hostSpec, hostPos);
// insert url spec corresponding to host name // insert url spec corresponding to host name
if (hostSpec.EqualsIgnoreCase("ftp")) { if (hostSpec.EqualsIgnoreCase("ftp")) {
urlSpec.Insert("ftp://", 0, 6); urlSpec.Insert("ftp://", 0, 6);
} else { } else {
urlSpec.Insert("http://", 0, 7); urlSpec.Insert("http://", 0, 7);
} }
} // end if colon } // end if colon
rv = NS_NewURI(getter_AddRefs(uri), urlSpec, nsnull); rv = NS_NewURI(getter_AddRefs(uri), urlSpec, nsnull);
nsAutoString url(aURLSpec); nsAutoString url(aURLSpec);
if (((url.Find("mailto:", PR_TRUE))<0) && (NS_FAILED(rv))) { if (((url.Find("mailto:", PR_TRUE))<0) && (NS_FAILED(rv))) {
// no dice, even more tricks? // no dice, even more tricks?
return rv; return rv;
}
} }
} }