From 196f89df7e222493c3e1307a911ef2404166d195 Mon Sep 17 00:00:00 2001 From: "valeski%netscape.com" Date: Sun, 9 Aug 1998 21:22:18 +0000 Subject: [PATCH] moved http:// assumption code into nsWebShell.cpp from nsBrowserWindow.cpp git-svn-id: svn://10.0.0.236/trunk@7639 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/docshell/base/nsWebShell.cpp | 18 ++++++++++++++++-- mozilla/webshell/src/nsWebShell.cpp | 18 ++++++++++++++++-- 2 files changed, 32 insertions(+), 4 deletions(-) diff --git a/mozilla/docshell/base/nsWebShell.cpp b/mozilla/docshell/base/nsWebShell.cpp index 4ecc41e91f6..01e098de292 100644 --- a/mozilla/docshell/base/nsWebShell.cpp +++ b/mozilla/docshell/base/nsWebShell.cpp @@ -797,9 +797,23 @@ nsWebShell::LoadURL(const nsString& aURLSpec, nsIPostData* aPostData) { nsresult rv; - - // Give web-shell-container right of refusal + PRInt32 colon, fSlash; + PRUnichar port; nsAutoString urlSpec(aURLSpec); + + fSlash=urlSpec.Find('/'); + + // 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); + } + // Give web-shell-container right of refusal if (nsnull != mContainer) { rv = mContainer->WillLoadURL(this, urlSpec); if (NS_OK != rv) { diff --git a/mozilla/webshell/src/nsWebShell.cpp b/mozilla/webshell/src/nsWebShell.cpp index 4ecc41e91f6..01e098de292 100644 --- a/mozilla/webshell/src/nsWebShell.cpp +++ b/mozilla/webshell/src/nsWebShell.cpp @@ -797,9 +797,23 @@ nsWebShell::LoadURL(const nsString& aURLSpec, nsIPostData* aPostData) { nsresult rv; - - // Give web-shell-container right of refusal + PRInt32 colon, fSlash; + PRUnichar port; nsAutoString urlSpec(aURLSpec); + + fSlash=urlSpec.Find('/'); + + // 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); + } + // Give web-shell-container right of refusal if (nsnull != mContainer) { rv = mContainer->WillLoadURL(this, urlSpec); if (NS_OK != rv) {