Bug 162050 - Gopher URLs processed noncompliantly

r=dmose, sr=bzbarsky
This commit is contained in:
bbaetz%student.usyd.edu.au 2002-08-12 01:06:27 +00:00
parent d5a71f390e
commit 73ad3b526d
2 changed files with 14 additions and 3 deletions

View File

@ -115,10 +115,21 @@ nsGopherChannel::Init(nsIURI* uri, nsIProxyInfo* proxyInfo)
// No path given
if (buffer[0]=='\0' || (buffer[0]=='/' && buffer[1]=='\0')) {
mType = '1';
mSelector.Adopt(nsCRT::strdup(""));
mSelector.Truncate();
} else {
mType = buffer[1]; // Ignore leading '/'
mSelector.Adopt(nsCRT::strdup(nsUnescape(NS_CONST_CAST(char*,buffer.get()+2))));
// Do it this way in case selector contains embedded nulls after
// unescaping
char* selector = nsCRT::strdup(buffer.get()+2);
PRInt32 count = nsUnescapeCount(selector);
mSelector.Assign(selector,count);
nsCRT::free(selector);
if (mSelector.FindCharInSet(nsCString("\t\n\r\0",4)) != -1) {
// gopher selectors cannot containt tab, cr, lf, or \0
return NS_ERROR_MALFORMED_URI;
}
}
PR_LOG(gGopherLog,

View File

@ -82,7 +82,7 @@ protected:
nsXPIDLCString mHost;
PRInt32 mPort;
char mType;
nsXPIDLCString mSelector;
nsCString mSelector;
nsCString mRequest;
nsCOMPtr<nsISupports> mResponseContext;