From dc04c5339fc32964c7cbf20de3206f97c8ea0fc6 Mon Sep 17 00:00:00 2001 From: "kipp%netscape.com" Date: Fri, 24 Jul 1998 18:16:05 +0000 Subject: [PATCH] Handle absolute url's better git-svn-id: svn://10.0.0.236/trunk@6405 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/network/module/nsURL.cpp | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/mozilla/network/module/nsURL.cpp b/mozilla/network/module/nsURL.cpp index f6d55447d12..db8cceb74b7 100644 --- a/mozilla/network/module/nsURL.cpp +++ b/mozilla/network/module/nsURL.cpp @@ -266,8 +266,29 @@ nsresult URLImpl::ParseURL(const nsIURL* aURL, const nsString& aSpec) } } - const char* cp = PL_strchr(cSpec, ':'); - if ((nsnull == cp) || ('/' == cSpec[0])) { + // The URL is considered absolute if and only if it begins with a + // protocol spec. A protocol spec is an alphanumeric string of 1 or + // more characters that is terminated with a colon. + PRBool isAbsolute = PR_FALSE; + char* cp; + char* ap = cSpec; + char ch; + while (0 != (ch = *ap)) { + if (((ch >= 'a') && (ch <= 'z')) || + ((ch >= 'A') && (ch <= 'Z')) || + ((ch >= '0') && (ch <= '9'))) { + ap++; + continue; + } + if ((ch == ':') && (ap - cSpec >= 2)) { + isAbsolute = PR_TRUE; + cp = ap; + break; + } + break; + } + + if (!isAbsolute) { // relative spec if (nsnull == aURL) { delete cSpec;