From f49c76a6d8cbc6d4684a13cb4d271fe0fccf4237 Mon Sep 17 00:00:00 2001 From: "andreas.otte%primus-online.de" Date: Fri, 14 Jul 2000 22:21:52 +0000 Subject: [PATCH] fix for bug 42342 [[regression] Text before ':' in URL is interpreted as protocol], we now try the www...com trick instead, not much better, but in alignment with our current fixup strategy, r=valeski@netscape.com, a=waterson@mozilla.org git-svn-id: svn://10.0.0.236/trunk@74264 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/docshell/base/nsDocShell.cpp | 40 +++++++++++----------------- 1 file changed, 16 insertions(+), 24 deletions(-) diff --git a/mozilla/docshell/base/nsDocShell.cpp b/mozilla/docshell/base/nsDocShell.cpp index 5e57feacdfe..0048b7bfca4 100644 --- a/mozilla/docshell/base/nsDocShell.cpp +++ b/mozilla/docshell/base/nsDocShell.cpp @@ -2632,32 +2632,24 @@ NS_IMETHODIMP nsDocShell::CreateFixupURI(const PRUnichar* aStringURI, return NS_OK; // See if a protocol needs to be added - PRInt32 colon = uriString.FindChar(':'); - PRInt32 fSlash = uriString.FindChar('/'); - PRUnichar port = nsnull;; - // if no scheme (protocol) is found, assume http. - if (colon == -1 || fSlash == -1 || (fSlash > -1) && (colon+1 != fSlash)) { - if (colon < (((PRInt32)uriString.Length())-1)) { - if (colon != -1) port = uriString.CharAt(colon+1); - if (colon == -1 || uriString.IsDigit(port) || - uriString.CharAt(0) == '[') { - // find host name - PRInt32 hostPos = uriString.FindCharInSet("./:"); - if (hostPos == -1) - hostPos = uriString.Length(); + PRInt32 checkprotocol = uriString.Find("://",0); + // if no scheme (protocol) is found, assume http or ftp. + if (checkprotocol == -1) { + // find host name + PRInt32 hostPos = uriString.FindCharInSet("./:"); + if (hostPos == -1) + hostPos = uriString.Length(); - // extract host name - nsAutoString hostSpec; - uriString.Left(hostSpec, hostPos); + // extract host name + nsAutoString hostSpec; + uriString.Left(hostSpec, hostPos); - // insert url spec corresponding to host name - if (hostSpec.EqualsIgnoreCase("ftp")) - uriString.InsertWithConversion("ftp://", 0, 6); - else - uriString.InsertWithConversion("http://", 0, 7); - } - } - } // end if colon + // insert url spec corresponding to host name + if (hostSpec.EqualsIgnoreCase("ftp")) + uriString.InsertWithConversion("ftp://", 0, 6); + else + uriString.InsertWithConversion("http://", 0, 7); + } // end if checkprotocol return NS_NewURI(aURI, uriString.GetUnicode(), nsnull); }