bug 40670 [URL: resolution of protocol:/path] checking in the groundwork to have an easy fix if we ever decide to support these kind of deprecated relative urls. For that a new attribute URIType is added to nsIProtocolHandler and its implementations to store some protocol/scheme dependend information to have enough information to allow correct parsing. r=darin@netscape.com sr=rpotts@netscape.com

This commit is contained in:
andreas.otte%primus-online.de 2001-08-07 20:42:57 +00:00
Родитель 4fea47e89a
Коммит c6853783af
34 изменённых файлов: 254 добавлений и 11 удалений

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

@ -521,6 +521,13 @@ nsChromeProtocolHandler::AllowPort(PRInt32 port, const char *scheme, PRBool *_re
return NS_OK;
}
NS_IMETHODIMP
nsChromeProtocolHandler::GetURIType(PRInt16 *result)
{
*result = URI_STD;
return NS_OK;
}
NS_IMETHODIMP
nsChromeProtocolHandler::NewURI(const char *aSpec, nsIURI *aBaseURI,
nsIURI **result)

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

@ -77,6 +77,15 @@ nsLDAPProtocolHandler::GetDefaultPort(PRInt32 *result)
return NS_OK;
}
// getter method for uritype attribute
//
NS_IMETHODIMP
nsLDAPProtocolHandler::GetURIType(PRInt16 *result)
{
*result = URI_NORELATIVE;
return NS_OK;
}
// construct an appropriate URI
//
NS_IMETHODIMP

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

@ -691,6 +691,13 @@ nsJSProtocolHandler::GetDefaultPort(PRInt32 *result)
return NS_OK;
}
NS_IMETHODIMP
nsJSProtocolHandler::GetURIType(PRInt16 *result)
{
*result = URI_NORELATIVE | URI_NOAUTH;
return NS_OK;
}
NS_IMETHODIMP
nsJSProtocolHandler::NewURI(const char *aSpec, nsIURI *aBaseURI,
nsIURI **result)

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

@ -72,6 +72,12 @@ nsDateTimeHandler::GetDefaultPort(PRInt32 *result) {
return NS_OK;
}
NS_IMETHODIMP
nsDateTimeHandler::GetURIType(PRInt16 *result) {
*result = URI_NORELATIVE | URI_NOAUTH;
return NS_OK;
}
NS_IMETHODIMP
nsDateTimeHandler::NewURI(const char *aSpec, nsIURI *aBaseURI,
nsIURI **result) {

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

@ -72,6 +72,12 @@ nsFingerHandler::GetDefaultPort(PRInt32 *result) {
return NS_OK;
}
NS_IMETHODIMP
nsFingerHandler::GetURIType(PRInt16 *result) {
*result = URI_NORELATIVE | URI_NOAUTH;
return NS_OK;
}
NS_IMETHODIMP
nsFingerHandler::NewURI(const char *aSpec, nsIURI *aBaseURI,
nsIURI **result) {

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

@ -59,6 +59,11 @@ NS_IMETHODIMP inBitmapProtocolHandler::GetDefaultPort(PRInt32 *result)
return NS_OK;
}
NS_IMETHODIMP inBitmapProtocolHandler::GetURIType(PRInt16 *result)
{
*result = URI_NORELATIVE;
return NS_OK;
}
NS_IMETHODIMP inBitmapProtocolHandler::AllowPort(PRInt32 port, const char *scheme, PRBool *_retval)
{

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

@ -162,6 +162,8 @@ function IRCProtocolHandler()
IRCProtocolHandler.prototype.scheme = "irc";
IRCProtocolHandler.prototype.defaultPort = 6667;
IRCProtocolHandler.prototype.URIType =
Components.interfaces.nsIProtocolHandler.URI_NORELATIVE;
IRCProtocolHandler.prototype.allowPort =
function (aPort, aScheme)

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

@ -154,6 +154,8 @@ function XMLTermProtocolHandler()
XMLTermProtocolHandler.prototype.scheme = "terminal";
XMLTermProtocolHandler.prototype.defaultPort = -1;
XMLTermProtocolHandler.prototype.URIType =
Components.interfaces.nsIProtocolHandler.URI_NORELATIVE;
XMLTermProtocolHandler.prototype.newURI =
function (aSpec, aBaseURI)

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

@ -94,6 +94,12 @@ NS_IMETHODIMP nsAddbookProtocolHandler::GetDefaultPort(PRInt32 *aDefaultPort)
return NS_OK;
}
NS_IMETHODIMP nsAddbookProtocolHandler::GetURIType(PRInt16 *aUritype)
{
*aUritype = URI_STD;
return NS_OK;
}
NS_IMETHODIMP nsAddbookProtocolHandler::NewURI(const char *aSpec, nsIURI *aBaseURI, nsIURI **_retval)
{
// get a new smtp url

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

@ -273,6 +273,12 @@ nsSmtpService::AllowPort(PRInt32 port, const char *scheme, PRBool *_retval)
return NS_OK;
}
NS_IMETHODIMP nsSmtpService::GetURIType(PRInt16 *result)
{
*result = URI_NORELATIVE;
return NS_OK;
}
//////////////////////////////////////////////////////////////////////////
// This is just a little stub channel class for mailto urls. Mailto urls
// don't really have any data for the stream calls in nsIChannel to make much sense.

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

@ -2976,6 +2976,12 @@ NS_IMETHODIMP nsImapService::GetDefaultPort(PRInt32 *aDefaultPort)
return NS_OK;
}
NS_IMETHODIMP nsImapService::GetURIType(PRInt16 *result)
{
*result = URI_STD;
return NS_OK;
}
NS_IMETHODIMP nsImapService::AllowPort(PRInt32 port, const char *scheme, PRBool *_retval)
{
// allow imap to run on any port

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

@ -43,6 +43,7 @@
#include "nsIDocShellLoadInfo.h"
#include "nsIWebNavigation.h"
#include "prprf.h"
#include "nsEscape.h"
static NS_DEFINE_CID(kIStreamConverterServiceCID,
NS_STREAMCONVERTERSERVICE_CID);
@ -349,7 +350,7 @@ nsresult nsMailboxService::PrepareMessageCopyUrl(nsIMsgFolder *folder, nsIUrlLis
urlSpec = PR_smprintf("mailbox://%s", (const char *) filePath);
nsCOMPtr <nsIMsgMailNewsUrl> url = do_QueryInterface(*aMailboxUrl);
url->SetSpec(urlSpec);
url->SetSpec(urlSpec);
PR_FREEIF(urlSpec);
(*aMailboxUrl)->SetMailboxAction(aMailboxAction);
@ -402,14 +403,16 @@ nsresult nsMailboxService::PrepareMessageUrl(const char * aSrcMsgMailboxURI, nsI
{
// set up the url spec and initialize the url with it.
nsFilePath filePath(folderPath); // convert to file url representation...
nsXPIDLCString escapedFilePath;
*((char**)getter_Copies(escapedFilePath)) =
nsEscape(filePath, url_Path);
if (mPrintingOperation)
urlSpec = PR_smprintf("mailbox://%s?number=%d&header=print", (const char *) filePath, msgKey);
urlSpec = PR_smprintf("mailbox://%s?number=%d&header=print", (const char *) escapedFilePath, msgKey);
else if (part)
urlSpec = PR_smprintf("mailbox://%s?number=%d&%s", (const char *)
filePath, msgKey, part);
escapedFilePath, msgKey, part);
else
urlSpec = PR_smprintf("mailbox://%s?number=%d", (const char *) filePath, msgKey);
urlSpec = PR_smprintf("mailbox://%s?number=%d", (const char *) escapedFilePath, msgKey);
nsCOMPtr <nsIMsgMailNewsUrl> url = do_QueryInterface(*aMailboxUrl);
url->SetSpec(urlSpec);
@ -462,6 +465,12 @@ NS_IMETHODIMP nsMailboxService::AllowPort(PRInt32 port, const char *scheme, PRBo
return NS_OK;
}
NS_IMETHODIMP nsMailboxService::GetURIType(PRInt16 *result)
{
*result = URI_STD;
return NS_OK;
}
NS_IMETHODIMP nsMailboxService::NewURI(const char *aSpec, nsIURI *aBaseURI, nsIURI **_retval)
{
nsCOMPtr<nsIMailboxUrl> aMsgUrl;

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

@ -326,6 +326,13 @@ NS_IMETHODIMP nsPop3Service::GetDefaultDoBiff(PRBool *aDoBiff)
return NS_OK;
}
NS_IMETHODIMP nsPop3Service::GetURIType(PRInt16 *result)
{
NS_ENSURE_ARG_POINTER(result);
*result = URI_NORELATIVE;
return NS_OK;
}
NS_IMETHODIMP nsPop3Service::NewURI(const char *aSpec, nsIURI *aBaseURI, nsIURI **_retval)
{
nsresult rv = NS_ERROR_FAILURE;

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

@ -1245,6 +1245,13 @@ nsNntpService::GetDefaultServerPort(PRBool isSecure, PRInt32 *aDefaultPort)
return rv;
}
NS_IMETHODIMP nsNntpService::GetURIType(PRInt16 *aUritype)
{
NS_ENSURE_ARG_POINTER(aUritype);
*aUritype = URI_NORELATIVE;
return NS_OK;
}
NS_IMETHODIMP nsNntpService::NewURI(const char *aSpec, nsIURI *aBaseURI, nsIURI **_retval)
{
nsresult rv = NS_OK;

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

@ -111,6 +111,16 @@ nsJARProtocolHandler::GetDefaultPort(PRInt32 *result)
return NS_OK;
}
NS_IMETHODIMP
nsJARProtocolHandler::GetURIType(PRInt16 *result)
{
*result = URI_NORELATIVE | URI_NOAUTH;
/* Although jar uris have their own concept of relative urls
it is very different from the standard behaviour, so we
have to say norelative here! */
return NS_OK;
}
NS_IMETHODIMP
nsJARProtocolHandler::NewURI(const char *aSpec, nsIURI *aBaseURI,
nsIURI **result)

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

@ -59,7 +59,6 @@ NS_IMETHODIMP nsIconProtocolHandler::GetDefaultPort(PRInt32 *result)
return NS_OK;
}
NS_IMETHODIMP nsIconProtocolHandler::AllowPort(PRInt32 port, const char *scheme, PRBool *_retval)
{
// don't override anything.
@ -67,6 +66,12 @@ NS_IMETHODIMP nsIconProtocolHandler::AllowPort(PRInt32 port, const char *scheme,
return NS_OK;
}
NS_IMETHODIMP nsIconProtocolHandler::GetURIType(PRInt16 *result)
{
*result = URI_NORELATIVE | URI_NOAUTH;
return NS_OK;
}
NS_IMETHODIMP nsIconProtocolHandler::NewURI(const char *aSpec, nsIURI *aBaseURI, nsIURI **result)
{
// no concept of a relative icon url

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

@ -39,6 +39,14 @@ interface nsIIOService : nsISupports
*/
nsIProtocolHandler getProtocolHandler(in string scheme);
/**
* Returns a uritype for a given scheme.
*
* @param scheme URI scheme
* @return returns short for uritype definition
*/
short getURIType(in string scheme);
/**
* This method constructs a new URI by first determining the scheme
* of the URI spec, and then delegating the construction of the URI

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

@ -30,14 +30,34 @@ interface nsIProtocolHandler : nsISupports
{
readonly attribute string scheme;
/**
* Default Port will be the port that this protocol normally
* uses. If a port does not make sense for the protocol (eg about://)
* -1 will be returned.
*/
/**
* Default Port will be the port that this protocol normally
* uses. If a port does not make sense for the protocol (eg about://)
* -1 will be returned.
*/
readonly attribute long defaultPort;
/**
* constants for the uritype mask
*/
/* the first is the default mask 0, the following masks are deviations */
/* standard full uri, has authority component and
has concept of relative uris (http, ftp, ...) */
const short URI_STD = 0;
/* no concept of relative uris, (about, rdf, javascript, finger, ...) */
const short URI_NORELATIVE = (1<<0);
/* no authority component (file, ...) */
const short URI_NOAUTH = (1<<1);
/* more to come as needed */
readonly attribute short URIType;
/**
* Makes a URI object that is suitable for loading by this protocol.
* In the usual case (when only the accessors provided by nsIURI are

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

@ -600,6 +600,19 @@ nsIOService::ExtractUrlPart(const char *urlString, PRInt16 flag, PRUint32 *start
return NS_OK;
}
NS_IMETHODIMP
nsIOService::GetURIType(const char* scheme, PRInt16 *uritype)
{
nsCOMPtr<nsIProtocolHandler> handler;
nsresult rv = GetProtocolHandler(scheme, getter_AddRefs(handler));
if (NS_FAILED(rv)) {
return rv;
}
rv = handler->GetURIType(uritype);
return rv;
}
nsresult
nsIOService::NewURI(const char* aSpec, nsIURI* aBaseURI, nsIURI* *result)
{

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

@ -91,6 +91,13 @@ nsAboutProtocolHandler::GetDefaultPort(PRInt32 *result)
return NS_OK;
}
NS_IMETHODIMP
nsAboutProtocolHandler::GetURIType(PRInt16 *result)
{
*result = URI_NORELATIVE | URI_NOAUTH;
return NS_OK;
}
NS_IMETHODIMP
nsAboutProtocolHandler::NewURI(const char *aSpec, nsIURI *aBaseURI,
nsIURI **result)

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

@ -73,6 +73,12 @@ nsDataHandler::GetDefaultPort(PRInt32 *result) {
return NS_OK;
}
NS_IMETHODIMP
nsDataHandler::GetURIType(PRInt16 *result) {
*result = URI_NORELATIVE | URI_NOAUTH;
return NS_OK;
}
NS_IMETHODIMP
nsDataHandler::NewURI(const char *aSpec, nsIURI *aBaseURI,
nsIURI **result) {

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

@ -72,6 +72,12 @@ nsDateTimeHandler::GetDefaultPort(PRInt32 *result) {
return NS_OK;
}
NS_IMETHODIMP
nsDateTimeHandler::GetURIType(PRInt16 *result) {
*result = URI_NORELATIVE | URI_NOAUTH;
return NS_OK;
}
NS_IMETHODIMP
nsDateTimeHandler::NewURI(const char *aSpec, nsIURI *aBaseURI,
nsIURI **result) {

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

@ -95,6 +95,13 @@ nsFileProtocolHandler::GetDefaultPort(PRInt32 *result)
return NS_OK;
}
NS_IMETHODIMP
nsFileProtocolHandler::GetURIType(PRInt16 *result)
{
*result = URI_NOAUTH;
return NS_OK;
}
NS_IMETHODIMP
nsFileProtocolHandler::NewURI(const char *aSpec, nsIURI *aBaseURI,
nsIURI **result)

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

@ -72,6 +72,12 @@ nsFingerHandler::GetDefaultPort(PRInt32 *result) {
return NS_OK;
}
NS_IMETHODIMP
nsFingerHandler::GetURIType(PRInt16 *result) {
*result = URI_NORELATIVE | URI_NOAUTH;
return NS_OK;
}
NS_IMETHODIMP
nsFingerHandler::NewURI(const char *aSpec, nsIURI *aBaseURI,
nsIURI **result) {

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

@ -136,6 +136,13 @@ nsFtpProtocolHandler::GetDefaultPort(PRInt32 *result)
return NS_OK;
}
NS_IMETHODIMP
nsFtpProtocolHandler::GetURIType(PRInt16 *result)
{
*result = URI_STD;
return NS_OK;
}
NS_IMETHODIMP
nsFtpProtocolHandler::NewURI(const char *aSpec, nsIURI *aBaseURI,
nsIURI **result)

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

@ -89,6 +89,12 @@ nsGopherHandler::GetDefaultPort(PRInt32 *result) {
return NS_OK;
}
NS_IMETHODIMP
nsGopherHandler::GetURIType(PRInt16 *result) {
*result = URI_NORELATIVE;
return NS_OK;
}
NS_IMETHODIMP
nsGopherHandler::NewURI(const char *aSpec, nsIURI *aBaseURI,
nsIURI **result) {

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

@ -1536,6 +1536,13 @@ nsHttpHandler::GetDefaultPort(PRInt32 *aDefaultPort)
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsHttpHandler::GetURIType(PRInt16 *result)
{
*result = URI_STD;
return NS_OK;
}
NS_IMETHODIMP
nsHttpHandler::NewURI(const char *aSpec, nsIURI *aBaseURI, nsIURI **aURI)
{

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

@ -111,6 +111,16 @@ nsJARProtocolHandler::GetDefaultPort(PRInt32 *result)
return NS_OK;
}
NS_IMETHODIMP
nsJARProtocolHandler::GetURIType(PRInt16 *result)
{
*result = URI_NORELATIVE | URI_NOAUTH;
/* Although jar uris have their own concept of relative urls
it is very different from the standard behaviour, so we
have to say norelative here! */
return NS_OK;
}
NS_IMETHODIMP
nsJARProtocolHandler::NewURI(const char *aSpec, nsIURI *aBaseURI,
nsIURI **result)

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

@ -95,6 +95,12 @@ nsKeywordProtocolHandler::GetDefaultPort(PRInt32 *result) {
return NS_OK;
}
NS_IMETHODIMP
nsKeywordProtocolHandler::GetURIType(PRInt16 *result) {
*result = URI_NORELATIVE | URI_NOAUTH;
return NS_OK;
}
// digests a spec _without_ the preceeding "keyword:" scheme.
static char *
MangleKeywordIntoHTTPURL(const char *aSpec, const char *aHTTPURL) {

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

@ -182,6 +182,13 @@ nsResProtocolHandler::GetDefaultPort(PRInt32 *result)
return NS_OK;
}
NS_IMETHODIMP
nsResProtocolHandler::GetURIType(PRInt16 *result)
{
*result = URI_STD;
return NS_OK;
}
NS_IMETHODIMP
nsResProtocolHandler::NewURI(const char *aSpec, nsIURI *aBaseURI,
nsIURI **result)

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

@ -120,6 +120,13 @@ nsThemeHandler::GetDefaultPort(PRInt32 *result)
return NS_OK;
}
NS_IMETHODIMP
nsThemeHandler::GetURIType(PRInt16 *result)
{
*result = URI_NORELATIVE | URI_NOAUTH;
return NS_OK;
}
NS_IMETHODIMP
nsThemeHandler::NewURI(const char *aSpec, nsIURI *aBaseURI, nsIURI **result)
{

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

@ -73,6 +73,12 @@ nsViewSourceHandler::GetDefaultPort(PRInt32 *result) {
return NS_OK;
}
NS_IMETHODIMP
nsViewSourceHandler::GetURIType(PRInt16 *result) {
*result = URI_NORELATIVE | URI_NOAUTH;
return NS_OK;
}
NS_IMETHODIMP
nsViewSourceHandler::NewURI(const char *aSpec, nsIURI *aBaseURI,
nsIURI **result) {

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

@ -521,6 +521,13 @@ nsChromeProtocolHandler::AllowPort(PRInt32 port, const char *scheme, PRBool *_re
return NS_OK;
}
NS_IMETHODIMP
nsChromeProtocolHandler::GetURIType(PRInt16 *result)
{
*result = URI_STD;
return NS_OK;
}
NS_IMETHODIMP
nsChromeProtocolHandler::NewURI(const char *aSpec, nsIURI *aBaseURI,
nsIURI **result)

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

@ -302,6 +302,13 @@ PRBool nsExternalProtocolHandler::HaveProtocolHandler(nsIURI * aURI)
return haveHandler;
}
NS_IMETHODIMP nsExternalProtocolHandler::GetURIType(PRInt16 *aUritype)
{
// Make it norelative since it is a simple uri
*aUritype = URI_NORELATIVE;
return NS_OK;
}
NS_IMETHODIMP nsExternalProtocolHandler::NewURI(const char *aSpec, nsIURI *aBaseURI, nsIURI **_retval)
{
nsresult rv = NS_ERROR_UNKNOWN_PROTOCOL;