Added in code from bug #1935 to improve auto-protocol handling on urls
git-svn-id: svn://10.0.0.236/trunk@17443 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
parent
192c334fda
commit
36cc1ed161
@ -1200,13 +1200,31 @@ nsWebShell::LoadURL(const PRUnichar *aURLSpec,
|
||||
|
||||
// if no scheme (protocol) is found, assume http.
|
||||
if ( ((colon=urlSpec.Find(':')) == -1) // no colon at all
|
||||
|| ( (fSlash > -1) && (colon > fSlash) ) // the only colon comes after the first slash
|
||||
|| ( (colon < urlSpec.Length()-1) // the first char after the first colon is a digit (i.e. a port)
|
||||
&& ((port=urlSpec.CharAt(colon+1)) < '9')
|
||||
&& (port > '0') )
|
||||
) {
|
||||
nsString httpDef("http://");
|
||||
urlSpec.Insert(httpDef, 0, 7);
|
||||
|| ( (fSlash > -1) && (colon > fSlash) ) // the only colon comes after the first slash
|
||||
|| ( (colon < urlSpec.Length()-1) // the first char after the first colon is a digit (i.e. a port)
|
||||
&& ((port=urlSpec.CharAt(colon+1)) <= '9')
|
||||
&& (port > '0') )) {
|
||||
// find host name
|
||||
int hostPos = urlSpec.FindCharInSet("./:");
|
||||
if (hostPos == -1) {
|
||||
hostPos = urlSpec.Length();
|
||||
}
|
||||
|
||||
// extract host name
|
||||
nsAutoString hostSpec;
|
||||
urlSpec.Left(hostSpec, hostPos);
|
||||
|
||||
// insert url spec corresponding to host name
|
||||
if (hostSpec.EqualsIgnoreCase("www")) {
|
||||
nsString ftpDef("http://");
|
||||
urlSpec.Insert(ftpDef, 0, 7);
|
||||
} else if (hostSpec.EqualsIgnoreCase("ftp")) {
|
||||
nsString ftpDef("ftp://");
|
||||
urlSpec.Insert(ftpDef, 0, 6);
|
||||
} else {
|
||||
nsString httpDef("http://");
|
||||
urlSpec.Insert(httpDef, 0, 7);
|
||||
}
|
||||
}
|
||||
|
||||
// Give web-shell-container right of refusal
|
||||
|
||||
@ -1200,13 +1200,31 @@ nsWebShell::LoadURL(const PRUnichar *aURLSpec,
|
||||
|
||||
// if no scheme (protocol) is found, assume http.
|
||||
if ( ((colon=urlSpec.Find(':')) == -1) // no colon at all
|
||||
|| ( (fSlash > -1) && (colon > fSlash) ) // the only colon comes after the first slash
|
||||
|| ( (colon < urlSpec.Length()-1) // the first char after the first colon is a digit (i.e. a port)
|
||||
&& ((port=urlSpec.CharAt(colon+1)) < '9')
|
||||
&& (port > '0') )
|
||||
) {
|
||||
nsString httpDef("http://");
|
||||
urlSpec.Insert(httpDef, 0, 7);
|
||||
|| ( (fSlash > -1) && (colon > fSlash) ) // the only colon comes after the first slash
|
||||
|| ( (colon < urlSpec.Length()-1) // the first char after the first colon is a digit (i.e. a port)
|
||||
&& ((port=urlSpec.CharAt(colon+1)) <= '9')
|
||||
&& (port > '0') )) {
|
||||
// find host name
|
||||
int hostPos = urlSpec.FindCharInSet("./:");
|
||||
if (hostPos == -1) {
|
||||
hostPos = urlSpec.Length();
|
||||
}
|
||||
|
||||
// extract host name
|
||||
nsAutoString hostSpec;
|
||||
urlSpec.Left(hostSpec, hostPos);
|
||||
|
||||
// insert url spec corresponding to host name
|
||||
if (hostSpec.EqualsIgnoreCase("www")) {
|
||||
nsString ftpDef("http://");
|
||||
urlSpec.Insert(ftpDef, 0, 7);
|
||||
} else if (hostSpec.EqualsIgnoreCase("ftp")) {
|
||||
nsString ftpDef("ftp://");
|
||||
urlSpec.Insert(ftpDef, 0, 6);
|
||||
} else {
|
||||
nsString httpDef("http://");
|
||||
urlSpec.Insert(httpDef, 0, 7);
|
||||
}
|
||||
}
|
||||
|
||||
// Give web-shell-container right of refusal
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user