Changes from andreas.otte@primus-online.de for numerous URL parsing bugs. r=warren

This commit is contained in:
warren%netscape.com 2000-01-14 08:50:03 +00:00
Родитель d9d117bd67
Коммит d6a205f1ec
26 изменённых файлов: 904 добавлений и 983 удалений

Просмотреть файл

@ -66,7 +66,7 @@ public:
NS_ADDREF(mURL);
mHashValue = 0;
char* urlStr;
char* urlStr = nsnull;
mURL->GetSpec(&urlStr);
if (urlStr) {
mHashValue = nsCRT::HashValue(urlStr);

Просмотреть файл

@ -66,7 +66,7 @@ public:
NS_ADDREF(mURL);
mHashValue = 0;
char* urlStr;
char* urlStr = nsnull;
mURL->GetSpec(&urlStr);
if (urlStr) {
mHashValue = nsCRT::HashValue(urlStr);

Просмотреть файл

@ -66,7 +66,7 @@ public:
NS_ADDREF(mURL);
mHashValue = 0;
char* urlStr;
char* urlStr = nsnull;
mURL->GetSpec(&urlStr);
if (urlStr) {
mHashValue = nsCRT::HashValue(urlStr);

Просмотреть файл

@ -309,7 +309,6 @@ NS_IMETHODIMP nsMsgMailNewsUrl::SetScheme(const char * aScheme)
return m_baseURL->SetScheme(aScheme);
}
NS_IMETHODIMP nsMsgMailNewsUrl::GetPreHost(char * *aPreHost)
{
return m_baseURL->GetPreHost(aPreHost);
@ -320,6 +319,26 @@ NS_IMETHODIMP nsMsgMailNewsUrl::SetPreHost(const char * aPreHost)
return m_baseURL->SetPreHost(aPreHost);
}
NS_IMETHODIMP nsMsgMailNewsUrl::GetUsername(char * *aUsername)
{
return m_baseURL->GetUsername(aUsername);
}
NS_IMETHODIMP nsMsgMailNewsUrl::SetUsername(const char * aUsername)
{
return m_baseURL->SetUsername(aUsername);
}
NS_IMETHODIMP nsMsgMailNewsUrl::GetPassword(char * *aPassword)
{
return m_baseURL->GetPassword(aPassword);
}
NS_IMETHODIMP nsMsgMailNewsUrl::SetPassword(const char * aPassword)
{
return m_baseURL->SetPassword(aPassword);
}
NS_IMETHODIMP nsMsgMailNewsUrl::GetHost(char * *aHost)
{
return m_baseURL->GetHost(aHost);
@ -350,12 +369,21 @@ NS_IMETHODIMP nsMsgMailNewsUrl::SetPath(const char * aPath)
return m_baseURL->SetPath(aPath);
}
NS_IMETHODIMP nsMsgMailNewsUrl::GetURLParser(nsIURLParser * *aURLParser)
{
return m_baseURL->GetURLParser(aURLParser);
}
NS_IMETHODIMP nsMsgMailNewsUrl::SetURLParser(nsIURLParser* aURLParser)
{
return m_baseURL->SetURLParser(aURLParser);
}
NS_IMETHODIMP nsMsgMailNewsUrl::Equals(nsIURI *other, PRBool *_retval)
{
return m_baseURL->Equals(other, _retval);
}
NS_IMETHODIMP nsMsgMailNewsUrl::Clone(nsIURI **_retval)
{
return m_baseURL->Clone(_retval);
@ -389,22 +417,22 @@ NS_IMETHODIMP nsMsgMailNewsUrl::GetFileName(char * *aFileName)
NS_IMETHODIMP nsMsgMailNewsUrl::GetFileBaseName(char * *aFileBaseName)
{
return NS_ERROR_NOT_IMPLEMENTED;
return m_baseURL->GetFileBaseName(aFileBaseName);
}
NS_IMETHODIMP nsMsgMailNewsUrl::SetFileBaseName(const char * aFileBaseName)
{
return NS_ERROR_NOT_IMPLEMENTED;
return m_baseURL->SetFileBaseName(aFileBaseName);
}
NS_IMETHODIMP nsMsgMailNewsUrl::GetFileExtension(char * *aFileExtension)
{
return NS_ERROR_NOT_IMPLEMENTED;
return m_baseURL->GetFileExtension(aFileExtension);
}
NS_IMETHODIMP nsMsgMailNewsUrl::SetFileExtension(const char * aFileExtension)
{
return NS_ERROR_NOT_IMPLEMENTED;
return m_baseURL->SetFileExtension(aFileExtension);
}
NS_IMETHODIMP nsMsgMailNewsUrl::SetFileName(const char * aFileName)

Просмотреть файл

@ -318,6 +318,26 @@ NS_IMETHODIMP nsMailtoUrl::SetPreHost(const char * aPreHost)
return m_baseURL->SetPreHost(aPreHost);
}
NS_IMETHODIMP nsMailtoUrl::GetUsername(char * *aUsername)
{
return m_baseURL->GetUsername(aUsername);
}
NS_IMETHODIMP nsMailtoUrl::SetUsername(const char * aUsername)
{
return m_baseURL->SetUsername(aUsername);
}
NS_IMETHODIMP nsMailtoUrl::GetPassword(char * *aPassword)
{
return m_baseURL->GetPassword(aPassword);
}
NS_IMETHODIMP nsMailtoUrl::SetPassword(const char * aPassword)
{
return m_baseURL->SetPassword(aPassword);
}
NS_IMETHODIMP nsMailtoUrl::GetHost(char * *aHost)
{
return m_baseURL->GetHost(aHost);
@ -348,6 +368,16 @@ NS_IMETHODIMP nsMailtoUrl::SetPath(const char * aPath)
return m_baseURL->SetPath(aPath);
}
NS_IMETHODIMP nsMailtoUrl::GetURLParser(nsIURLParser * *aURLParser)
{
return m_baseURL->GetURLParser(aURLParser);
}
NS_IMETHODIMP nsMailtoUrl::SetURLParser(nsIURLParser * aURLParser)
{
return m_baseURL->SetURLParser(aURLParser);
}
NS_IMETHODIMP nsMailtoUrl::Equals(nsIURI *other, PRBool *_retval)
{
return m_baseURL->Equals(other, _retval);

Просмотреть файл

@ -157,6 +157,30 @@ nsJARURI::SetPreHost(const char * aPreHost)
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP
nsJARURI::GetUsername(char * *aUsername)
{
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP
nsJARURI::SetUsername(const char * aUsername)
{
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP
nsJARURI::GetPassword(char * *aPassword)
{
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP
nsJARURI::SetPassword(const char * aPassword)
{
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP
nsJARURI::GetHost(char * *aHost)
{
@ -193,6 +217,18 @@ nsJARURI::SetPath(const char * aPath)
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP
nsJARURI::GetURLParser(nsIURLParser * *aURLParser)
{
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP
nsJARURI::SetURLParser(nsIURLParser * aURLParser)
{
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP
nsJARURI::Equals(nsIURI *other, PRBool *_retval)
{

Просмотреть файл

@ -51,6 +51,7 @@ XPIDLSRCS = \
nsIUnicharStreamLoader.idl \
nsINetPrompt.idl \
nsISocketTransport.idl \
nsIURLParser.idl \
$(NULL)
EXPORTS = \

Просмотреть файл

@ -50,8 +50,9 @@ XPIDLSRCS = \
.\nsIStatusCodeEventSink.idl \
.\nsIFileSystem.idl \
.\nsIUnicharStreamLoader.idl \
.\nsINetPrompt.idl \
.\nsISocketTransport.idl \
.\nsINetPrompt.idl \
.\nsISocketTransport.idl \
.\nsIURLParser.idl \
$(NULL)
include <$(DEPTH)/config/rules.mak>

Просмотреть файл

@ -39,6 +39,20 @@ interface nsILoadGroupObserver;
[scriptable, uuid(1daf19f0-8ea7-11d3-93ad-00104ba0fd40)]
interface nsIIOService : nsISupports
{
/**
* constants for the Escape mask in the call to URLEscape
*/
const short url_Scheme = (1<<0);
const short url_Username = (1<<1);
const short url_Password = (1<<2);
const short url_Host = (1<<3);
const short url_Directory = (1<<4);
const short url_FileBaseName = (1<<5);
const short url_FileExtension = (1<<6);
const short url_Param = (1<<7);
const short url_Query = (1<<8);
const short url_Ref = (1<<9);
/**
* Returns a protocol handler for a given URI scheme.
*/
@ -160,6 +174,18 @@ interface nsIIOService : nsISupports
* causing the dialer to come up).
*/
attribute boolean offline;
/**
* escapes the string str with mask
*/
void URLEscape (in string str,
in short mask,
out string result);
/**
* unescapes str
*/
void URLUnescape(in string str,
out string result);
};
%{C++

Просмотреть файл

@ -21,6 +21,7 @@
*/
#include "nsISupports.idl"
#include "nsIURLParser.idl"
/**
* URIs are essentially structured names for things -- anything.
@ -79,6 +80,10 @@ interface nsIURI : nsISupports
*/
attribute string preHost;
attribute string username;
attribute string password;
/**
* The Host is the internet domain name to which this URI refers.
* Note that it could be an IP address as well.
@ -103,6 +108,11 @@ interface nsIURI : nsISupports
*/
attribute string path;
/**
* This is a handle to the Parser used to parse the URI
*/
attribute nsIURLParser URLParser;
/**
* Note that this comparison is only on char* level. Use
* the scheme specific URI to do a more thorough check. For example,
@ -137,6 +147,7 @@ interface nsIURI : nsISupports
* This method subsumes the deprecated method nsIIOService::MakeAbsolute.
*/
string resolve(in string relativePath);
};
%{C++

Просмотреть файл

@ -29,7 +29,16 @@ include $(DEPTH)/config/autoconf.mk
MODULE = necko
LIBRARY_NAME = neckobase_s
EXPORTS = \
nsAuthURLParser.h \
nsNoAuthURLParser.h \
$(NULL)
CPPSRCS = \
nsURLHelper.cpp \
nsStdURLParser.cpp \
nsAuthURLParser.cpp \
nsNoAuthURLParser.cpp \
nsAsyncStreamListener.cpp \
nsSyncStreamListener.cpp \
nsIOService.cpp \
@ -53,4 +62,3 @@ override NO_SHARED_LIB=1
override NO_STATIC_LIB=
include $(topsrcdir)/config/rules.mk

Просмотреть файл

@ -27,6 +27,10 @@ LCFLAGS = -DWIN32_LEAN_AND_MEAN -D_IMPL_NS_NET
LIBRARY_NAME=neckobase_s
CPP_OBJS = \
.\$(OBJDIR)\nsURLHelper.obj \
.\$(OBJDIR)\nsStdURLParser.obj \
.\$(OBJDIR)\nsAuthURLParser.obj \
.\$(OBJDIR)\nsNoAuthURLParser.obj \
.\$(OBJDIR)\nsAsyncStreamListener.obj \
.\$(OBJDIR)\nsSyncStreamListener.obj \
.\$(OBJDIR)\nsIOService.obj \
@ -44,6 +48,11 @@ CPP_OBJS = \
.\$(OBJDIR)\nsUnicharStreamLoader.obj \
$(NULL)
EXPORTS = \
nsAuthURLParser.h \
nsNoAuthURLParser.h \
$(NULL)
INCS = $(INCS) \
-I$(DEPTH)\dist\include \
$(NULL)

Просмотреть файл

@ -411,4 +411,16 @@ nsIOService::SetOffline(PRBool offline)
return NS_OK;
}
NS_IMETHODIMP
nsIOService::URLEscape(const char* str, PRInt16 mask, char **result)
{
return nsURLEscape((char*)str,mask,result);
}
NS_IMETHODIMP
nsIOService::URLUnescape(const char* str, char **result)
{
return nsURLUnescape((char*)str,result);
}
////////////////////////////////////////////////////////////////////////////////

Просмотреть файл

@ -25,6 +25,7 @@
#include "nsIIOService.h"
#include "nsString2.h"
#include "nsURLHelper.h"
class nsIOService : public nsIIOService
{

Просмотреть файл

@ -27,6 +27,7 @@
#include "nsString.h"
#include "prmem.h"
#include "prprf.h"
#include "nsURLHelper.h"
static NS_DEFINE_CID(kSimpleURICID, NS_SIMPLEURI_CID);
static NS_DEFINE_CID(kThisSimpleURIImplementationCID,
@ -142,6 +143,30 @@ nsSimpleURI::SetPreHost(const char* preHost)
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP
nsSimpleURI::GetUsername(char* *result)
{
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP
nsSimpleURI::SetUsername(const char* userName)
{
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP
nsSimpleURI::GetPassword(char* *result)
{
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP
nsSimpleURI::SetPassword(const char* password)
{
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP
nsSimpleURI::GetHost(char* *result)
{
@ -181,6 +206,18 @@ nsSimpleURI::SetPath(const char* path)
return NS_OK;
}
NS_IMETHODIMP
nsSimpleURI::GetURLParser(nsIURLParser* *result)
{
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP
nsSimpleURI::SetURLParser(nsIURLParser* URLParser)
{
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP
nsSimpleURI::Equals(nsIURI* other, PRBool *result)
{
@ -229,8 +266,7 @@ nsSimpleURI::SetRelativePath(const char *i_RelativePath)
NS_IMETHODIMP
nsSimpleURI::Resolve(const char *relativePath, char **result)
{
NS_ASSERTION(PR_FALSE, "This is meaningless in hack context!");
return NS_ERROR_NOT_IMPLEMENTED;
return DupString(result,(char*)relativePath);
}
////////////////////////////////////////////////////////////////////////////////

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -24,6 +24,8 @@
#define nsStdURL_h__
#include "nsIURL.h"
#include "nsIURLParser.h"
#include "nsURLHelper.h"
#include "nsAgg.h"
#include "nsCRT.h"
#include "nsString.h" // REMOVE Later!!
@ -39,9 +41,10 @@
class nsStdURL : public nsIURL
{
public:
////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
// nsStdURL methods:
nsStdURL();
nsStdURL(const char* i_Spec, nsISupports* outer=nsnull);
nsStdURL(const nsStdURL& i_URL);
virtual ~nsStdURL();
@ -54,156 +57,67 @@ public:
NS_DECL_AGGREGATED
////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
// nsIURI methods:
NS_DECL_NSIURI
////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
// nsIURL methods:
NS_DECL_NSIURL
/* todo move this to protected later */
nsresult ParsePath(void);
protected:
nsresult Parse(void);
nsresult ReconstructPath(void);
nsresult ReconstructSpec(void);
enum Format { ESCAPED, UNESCAPED };
nsresult Parse(const char* i_Spec);
nsresult AppendString(nsCString& buffer, char* fromUnescapedStr,
Format toFormat, PRInt16 mask);
nsresult GetString(char** result, char* fromEscapedStr,
Format toFormat);
nsresult AppendPreHost(nsCString& buffer, char* i_Username,
char* i_Password, Format toFormat);
nsresult AppendFileName(nsCString& buffer, char* i_FileBaseName,
char* i_FileExtension, Format toFormat);
// Some handy functions
nsresult DupString(char* *o_Dest, const char* i_Src);
nsresult ExtractString(char* i_Src, char* *o_Dest, PRUint32 length);
protected:
char* mScheme;
char* mPreHost;
char* mUsername;
char* mPassword;
char* mHost;
PRInt32 mPort;
char* mPath;
char* mDirectory;
char* mFileName;
char* mFileBaseName;
char* mFileExtension;
char* mParam;
char* mQuery;
char* mRef;
char* mSpec;
nsIURLParser* mURLParser;
};
inline NS_METHOD
nsStdURL::GetSpec(char* *o_Spec)
{
return DupString(o_Spec, mSpec);
}
inline NS_METHOD
nsStdURL::GetScheme(char* *o_Scheme)
{
return DupString(o_Scheme, mScheme);
return GetString(o_Scheme, mScheme, UNESCAPED);
}
inline NS_METHOD
nsStdURL::GetPreHost(char* *o_PreHost)
nsStdURL::GetUsername(char* *o_Username)
{
return DupString(o_PreHost, mPreHost);
return GetString(o_Username, mUsername, UNESCAPED);
}
inline NS_METHOD
nsStdURL::GetPassword(char* *o_Password)
{
return GetString(o_Password, mPassword, UNESCAPED);
}
inline NS_METHOD
nsStdURL::GetHost(char* *o_Host)
{
return DupString(o_Host, mHost);
}
inline NS_METHOD
nsStdURL::GetPath(char* *o_Path)
{
return DupString(o_Path, mPath);
}
inline NS_METHOD
nsStdURL::GetDirectory(char* *o_Directory)
{
return DupString(o_Directory, mDirectory);
}
inline NS_METHOD
nsStdURL::GetFileName(char* *o_FileName)
{
return DupString(o_FileName, mFileName);
}
inline NS_METHOD
nsStdURL::GetFileExtension(char* *o_FileExtension)
{
if (!o_FileExtension)
return NS_ERROR_NULL_POINTER;
char *dot = mFileName;
if (dot) {
// find the last dot
while (*dot) dot++;
while ( (dot != mFileName) && (*dot != '.') ) dot--; // goto the dot.
if (*dot == '.') {
nsCAutoString ext(dot+1);
*o_FileExtension = ext.ToNewCString();
if (!*o_FileExtension) return NS_ERROR_OUT_OF_MEMORY;
} else {
*o_FileExtension = nsnull;
}
}
return NS_OK;
}
inline NS_METHOD
nsStdURL::SetFileExtension(const char* FileExtension)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
inline NS_METHOD
nsStdURL::GetRef(char* *o_Ref)
{
return DupString(o_Ref, mRef);
}
inline NS_METHOD
nsStdURL::GetParam(char **o_Param)
{
return DupString(o_Param, mParam);
}
inline NS_METHOD
nsStdURL::GetQuery(char* *o_Query)
{
return DupString(o_Query, mQuery);
}
inline NS_METHOD
nsStdURL::SetScheme(const char* i_Scheme)
{
if (mScheme) nsCRT::free(mScheme);
nsresult status = DupString(&mScheme, i_Scheme);
ReconstructSpec();
return status;
}
inline NS_METHOD
nsStdURL::SetPreHost(const char* i_PreHost)
{
if (mPreHost) nsCRT::free(mPreHost);
nsresult status = DupString(&mPreHost, i_PreHost);
ReconstructSpec();
return status;
}
inline NS_METHOD
nsStdURL::SetHost(const char* i_Host)
{
if (mHost) nsCRT::free(mHost);
nsresult status = DupString(&mHost, i_Host);
ReconstructSpec();
return status;
return GetString(o_Host, mHost, UNESCAPED);
}
inline NS_METHOD
@ -217,12 +131,84 @@ nsStdURL::GetPort(PRInt32 *aPort)
return NS_ERROR_NULL_POINTER;
}
inline NS_METHOD
nsStdURL::GetFileBaseName(char* *o_FileBaseName)
{
return GetString(o_FileBaseName, mFileBaseName, UNESCAPED);
}
inline NS_METHOD
nsStdURL::GetFileExtension(char* *o_FileExtension)
{
return GetString(o_FileExtension, mFileExtension, UNESCAPED);
}
inline NS_METHOD
nsStdURL::GetParam(char **o_Param)
{
return GetString(o_Param, mParam, UNESCAPED);
}
inline NS_METHOD
nsStdURL::GetQuery(char* *o_Query)
{
return GetString(o_Query, mQuery, UNESCAPED);
}
inline NS_METHOD
nsStdURL::GetRef(char* *o_Ref)
{
return GetString(o_Ref, mRef, UNESCAPED);
}
inline NS_METHOD
nsStdURL::SetScheme(const char* i_Scheme)
{
CRTFREEIF(mScheme);
return DupString(&mScheme, i_Scheme);
}
inline NS_METHOD
nsStdURL::SetUsername(const char* i_Username)
{
CRTFREEIF(mUsername);
return DupString(&mUsername, i_Username);
}
inline NS_METHOD
nsStdURL::SetPassword(const char* i_Password)
{
CRTFREEIF(mPassword);
return DupString(&mPassword, i_Password);
}
inline NS_METHOD
nsStdURL::SetHost(const char* i_Host)
{
CRTFREEIF(mHost);
return DupString(&mHost, i_Host);
}
inline NS_METHOD
nsStdURL::SetPort(PRInt32 aPort)
{
mPort = aPort;
ReconstructSpec();
return NS_OK;
}
inline NS_METHOD
nsStdURL::SetFileBaseName(const char* i_FileBaseName)
{
CRTFREEIF(mFileBaseName);
return DupString(&mFileBaseName, i_FileBaseName);
}
inline NS_METHOD
nsStdURL::SetFileExtension(const char* i_FileExtension)
{
CRTFREEIF(mFileExtension);
return DupString(&mFileExtension, i_FileExtension);
}
#endif // nsStdURL_h__

Просмотреть файл

@ -30,6 +30,9 @@
#include "nsSocketTransportService.h"
#include "nsSocketProviderService.h"
#include "nscore.h"
#include "nsStdURLParser.h"
#include "nsAuthURLParser.h"
#include "nsNoAuthURLParser.h"
#include "nsStdURL.h"
#include "nsSimpleURI.h"
#include "nsDnsService.h"
@ -98,7 +101,20 @@ static nsModuleComponentInfo gNetModuleInfo[] = {
{ "Load Group",
NS_LOADGROUP_CID,
"component://netscape/network/load-group",
nsLoadGroup::Create }
nsLoadGroup::Create },
{ "StdURLParser",
NS_STANDARDURLPARSER_CID,
"component://netscape/network/standard-urlparser",
nsStdURLParser::Create },
{ "AuthURLParser",
NS_AUTHORITYURLPARSER_CID,
"component://netscape/network/authority-urlparser",
nsAuthURLParser::Create },
{ "NoAuthURLParser",
NS_NOAUTHORITYURLPARSER_CID,
"component://netscape/network/no-authority-urlparser",
nsNoAuthURLParser::Create },
};
NS_IMPL_NSGETMODULE("net", gNetModuleInfo)

Двоичные данные
netwerk/macbuild/netwerk.mcp

Двоичный файл не отображается.

Двоичные данные
netwerk/macbuild/netwerkIDL.mcp

Двоичный файл не отображается.

Просмотреть файл

@ -23,6 +23,7 @@
#include "nsFileChannel.h"
#include "nsFileProtocolHandler.h"
#include "nsIURL.h"
#include "nsNoAuthURLParser.h"
#include "nsCRT.h"
#include "nsIComponentManager.h"
#include "nsIServiceManager.h"
@ -34,7 +35,8 @@
#include "nsFileSpec.h"
#include "nsAutoLock.h"
static NS_DEFINE_CID(kStandardURLCID, NS_STANDARDURL_CID);
static NS_DEFINE_CID(kStandardUrlCID, NS_STANDARDURL_CID);
static NS_DEFINE_CID(kNoAuthUrlParserCID, NS_NOAUTHORITYURLPARSER_CID);
////////////////////////////////////////////////////////////////////////////////
@ -103,17 +105,31 @@ nsFileProtocolHandler::NewURI(const char *aSpec, nsIURI *aBaseURI,
// file: URLs (currently) have no additional structure beyond that provided by standard
// URLs, so there is no "outer" given to CreateInstance
nsIURI* url;
nsIURI* url = nsnull;
nsIURLParser* urlparser = nsnull;
if (aBaseURI) {
rv = aBaseURI->Clone(&url);
if (NS_FAILED(rv)) return rv;
rv = url->SetRelativePath(aSpec);
}
else {
rv = nsComponentManager::CreateInstance(kStandardURLCID, nsnull,
NS_GET_IID(nsIURI),
(void**)&url);
rv = nsComponentManager::CreateInstance(kNoAuthUrlParserCID,
nsnull, NS_GET_IID(nsIURLParser),
(void**)&urlparser);
if (NS_FAILED(rv)) return rv;
rv = nsComponentManager::CreateInstance(kStandardUrlCID,
nsnull, NS_GET_IID(nsIURI),
(void**)&url);
if (NS_FAILED(rv)) {
NS_RELEASE(urlparser);
return rv;
}
rv = url->SetURLParser(urlparser);
if (NS_FAILED(rv)) {
NS_RELEASE(urlparser);
NS_RELEASE(url);
return rv;
}
rv = url->SetSpec((char*)aSpec);
}

Просмотреть файл

@ -23,6 +23,7 @@
#include "nsFtpProtocolHandler.h"
#include "nsFTPChannel.h"
#include "nsIURL.h"
#include "nsAuthURLParser.h"
#include "nsCRT.h"
#include "nsIComponentManager.h"
#include "nsIInterfaceRequestor.h"
@ -46,7 +47,8 @@ PRLogModuleInfo* gFTPLog = nsnull;
#endif /* PR_LOGGING */
static NS_DEFINE_CID(kStandardURLCID, NS_STANDARDURL_CID);
static NS_DEFINE_CID(kStandardUrlCID, NS_STANDARDURL_CID);
static NS_DEFINE_CID(kAuthUrlParserCID, NS_AUTHORITYURLPARSER_CID);
////////////////////////////////////////////////////////////////////////////////
@ -130,17 +132,31 @@ nsFtpProtocolHandler::NewURI(const char *aSpec, nsIURI *aBaseURI,
nsresult rv;
PR_LOG(gFTPLog, PR_LOG_ALWAYS, ("FTP attempt at %s ", aSpec));
nsIURI* url;
nsIURI* url = nsnull;
nsIURLParser* urlparser = nsnull;
if (aBaseURI) {
rv = aBaseURI->Clone(&url);
if (NS_FAILED(rv)) return rv;
rv = url->SetRelativePath(aSpec);
}
else {
rv = nsComponentManager::CreateInstance(kStandardURLCID, nsnull,
NS_GET_IID(nsIURI),
(void**)&url);
rv = nsComponentManager::CreateInstance(kAuthUrlParserCID,
nsnull, NS_GET_IID(nsIURLParser),
(void**)&urlparser);
if (NS_FAILED(rv)) return rv;
rv = nsComponentManager::CreateInstance(kStandardUrlCID,
nsnull, NS_GET_IID(nsIURI),
(void**)&url);
if (NS_FAILED(rv)) {
NS_RELEASE(urlparser);
return rv;
}
rv = url->SetURLParser(urlparser);
if (NS_FAILED(rv)) {
NS_RELEASE(urlparser);
NS_RELEASE(url);
return rv;
}
rv = url->SetSpec((char*)aSpec);
}
if (NS_FAILED(rv)) {

Просмотреть файл

@ -39,6 +39,8 @@
#include "nsHTTPEncodeStream.h"
#include "nsHTTPAtoms.h"
#include "nsFileSpec.h"
#include "nsAuthURLParser.h"
#include "nsIPref.h" // preferences stuff
#ifdef DEBUG_gagan
#include "nsUnixColorPrintf.h"
@ -63,6 +65,7 @@ PRLogModuleInfo* gHTTPLog = nsnull;
#define MAX_NUMBER_OF_OPEN_TRANSPORTS 8
static NS_DEFINE_CID(kStandardUrlCID, NS_STANDARDURL_CID);
static NS_DEFINE_CID(kAuthUrlParserCID, NS_AUTHORITYURLPARSER_CID);
static NS_DEFINE_CID(kSocketTransportServiceCID, NS_SOCKETTRANSPORTSERVICE_CID);
static NS_DEFINE_CID(kPrefServiceCID, NS_PREF_CID);
@ -264,6 +267,7 @@ nsHTTPHandler::NewURI(const char *aSpec, nsIURI *aBaseURI,
nsresult rv;
nsIURI* url = nsnull;
nsIURLParser* urlparser = nsnull;
if (aBaseURI)
{
rv = aBaseURI->Clone(&url);
@ -272,10 +276,23 @@ nsHTTPHandler::NewURI(const char *aSpec, nsIURI *aBaseURI,
}
else
{
rv = nsComponentManager::CreateInstance(kAuthUrlParserCID,
nsnull, NS_GET_IID(nsIURLParser),
(void**)&urlparser);
if (NS_FAILED(rv)) return rv;
rv = nsComponentManager::CreateInstance(kStandardUrlCID,
nsnull, NS_GET_IID(nsIURI),
(void**)&url);
if (NS_FAILED(rv)) return rv;
if (NS_FAILED(rv)) {
NS_RELEASE(urlparser);
return rv;
}
rv = url->SetURLParser(urlparser);
if (NS_FAILED(rv)) {
NS_RELEASE(urlparser);
NS_RELEASE(url);
return rv;
}
rv = url->SetSpec((char*)aSpec);
}
if (NS_FAILED(rv)) {

Просмотреть файл

@ -157,6 +157,30 @@ nsJARURI::SetPreHost(const char * aPreHost)
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP
nsJARURI::GetUsername(char * *aUsername)
{
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP
nsJARURI::SetUsername(const char * aUsername)
{
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP
nsJARURI::GetPassword(char * *aPassword)
{
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP
nsJARURI::SetPassword(const char * aPassword)
{
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP
nsJARURI::GetHost(char * *aHost)
{
@ -193,6 +217,18 @@ nsJARURI::SetPath(const char * aPath)
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP
nsJARURI::GetURLParser(nsIURLParser * *aURLParser)
{
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP
nsJARURI::SetURLParser(nsIURLParser * aURLParser)
{
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP
nsJARURI::Equals(nsIURI *other, PRBool *_retval)
{

Просмотреть файл

@ -121,7 +121,7 @@ nsResChannel::Substitutions::Init()
NS_ASSERTION(mSubstitutions == nsnull, "failed to call destructor");
char* root;
char* root = nsnull;
rv = channel->mResourceURI->GetHost(&root);
if (NS_SUCCEEDED(rv)) {
rv = channel->mHandler->GetSubstitutions(root, &mSubstitutions);

Просмотреть файл

@ -637,7 +637,7 @@ static const char kResourceURIPrefix[] = "resource:";
// XXX this is a hack: any "file:" URI is considered writable. All
// others are considered read-only.
char* realURL;
char* realURL = nsnull;
mURL->GetSpec(&realURL);
if ((PL_strncmp(realURL, kFileURIPrefix, sizeof(kFileURIPrefix) - 1) != 0) &&
(PL_strncmp(realURL, kResourceURIPrefix, sizeof(kResourceURIPrefix) - 1) != 0)) {