From 78da1efce2bd2f068be41ddf1bc70a4a483bc050 Mon Sep 17 00:00:00 2001 From: "andreas.otte%primus-online.de" Date: Sat, 13 May 2000 12:00:38 +0000 Subject: [PATCH] fix bug 32997, file URLs that include a hostname don't work, look for a hostname and do some special work on detecting drivenames for XP_PC, r=gagan@netscape.com git-svn-id: svn://10.0.0.236/trunk@69557 18797224-902f-48f8-a5cc-f745e15eee43 --- .../netwerk/base/src/nsNoAuthURLParser.cpp | 34 ++++++++++++++++--- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/mozilla/netwerk/base/src/nsNoAuthURLParser.cpp b/mozilla/netwerk/base/src/nsNoAuthURLParser.cpp index 22d343450e2..7adc63febe2 100644 --- a/mozilla/netwerk/base/src/nsNoAuthURLParser.cpp +++ b/mozilla/netwerk/base/src/nsNoAuthURLParser.cpp @@ -113,12 +113,36 @@ nsresult nsNoAuthURLParser::ParseAtHost(const char* i_Spec, char* *o_Host, PRInt32 *o_Port, char* *o_Path) { + // Usually there is no Host, but who knows ... nsresult rv = NS_OK; - // There is no Host, but take care of a localhost - if ((nsCRT::strcasecmp(i_Spec,"localhost")==0) || - (PL_strcasestr(i_Spec,"localhost/")==i_Spec)) - return ParseAtPath(i_Spec+9,o_Path); - rv = ParseAtPath(i_Spec, o_Path); + + PRInt32 len = PL_strlen(i_Spec); + if ((*i_Spec == '/') +#ifdef XP_PC + // special case for XP_PC: look for a drive + || (len > 1 && (*(i_Spec+1) == ':' || *(i_Spec+1) == '|')) +#endif + ){ + // No host, okay ... + rv = ParseAtPath(i_Spec, o_Path); + } else { + // There seems be a host, drop it + char* brk = PL_strchr(i_Spec, '/'); + if (!brk) { + // everything is the host + rv = DupString(o_Host, i_Spec); + if (NS_FAILED(rv)) return rv; + ToLowerCase(*o_Host); + // parse after the host + rv = ParseAtPath(i_Spec+len, o_Path); + } else { + rv = ExtractString((char*)i_Spec, o_Host, (brk - i_Spec)); + if (NS_FAILED(rv)) return rv; + ToLowerCase(*o_Host); + // parse after the host + rv = ParseAtPath(brk, o_Path); + } + } return rv; }