зеркало из https://github.com/mozilla/pjs.git
fixes bug 201040 "Unable to view page source of the page that uses IDN" r=biesi
This commit is contained in:
Родитель
b56b97c48b
Коммит
9fb553acda
|
@ -567,7 +567,7 @@
|
|||
}
|
||||
|
||||
/******************************************************************************
|
||||
* netwerk/protocol/data/ classes
|
||||
* netwerk/protocol/jar/ classes
|
||||
*/
|
||||
|
||||
#define NS_JARPROTOCOLHANDLER_CLASSNAME \
|
||||
|
@ -580,6 +580,18 @@
|
|||
{0x9f, 0x63, 0x00, 0x60, 0x08, 0xa6, 0xef, 0xe9} \
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* netwerk/protocol/viewsource/ classes
|
||||
*/
|
||||
|
||||
// service implementing nsIProtocolHandler
|
||||
#define NS_VIEWSOURCEHANDLER_CID \
|
||||
{ /* {0x9c7ec5d1-23f9-11d5-aea8-8fcc0793e97f} */ \
|
||||
0x9c7ec5d1, \
|
||||
0x23f9, \
|
||||
0x11d5, \
|
||||
{0xae, 0xa8, 0x8f, 0xcc, 0x07, 0x93, 0xe9, 0x7f} \
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* netwerk/dns/ classes
|
||||
|
|
|
@ -1,99 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "necko-config.h"
|
||||
#include "nsIGenericFactory.h"
|
||||
|
||||
#ifdef NECKO_PROTOCOL_gopher
|
||||
#include "nsGopherHandler.h"
|
||||
#endif
|
||||
|
||||
#ifdef NECKO_PROTOCOL_viewsource
|
||||
#include "nsViewSourceHandler.h"
|
||||
#endif
|
||||
|
||||
#ifdef NECKO_PROTOCOL_data
|
||||
#include "nsDataHandler.h"
|
||||
#endif
|
||||
|
||||
#ifdef NECKO_PROTOCOL_keyword
|
||||
#include "nsKeywordProtocolHandler.h"
|
||||
#endif
|
||||
|
||||
#include "nsNetCID.h"
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Module implementation for the net library
|
||||
|
||||
static const nsModuleComponentInfo gNetModuleInfo[] = {
|
||||
#ifdef NECKO_PROTOCOL_gopher
|
||||
//gopher:
|
||||
{ "The Gopher Protocol Handler",
|
||||
NS_GOPHERHANDLER_CID,
|
||||
NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX "gopher",
|
||||
nsGopherHandler::Create
|
||||
},
|
||||
#endif
|
||||
|
||||
#ifdef NECKO_PROTOCOL_data
|
||||
// from netwerk/protocol/data:
|
||||
{ "Data Protocol Handler",
|
||||
NS_DATAPROTOCOLHANDLER_CID,
|
||||
NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX "data",
|
||||
nsDataHandler::Create},
|
||||
#endif
|
||||
|
||||
#ifdef NECKO_PROTOCOL_keyword
|
||||
// from netwerk/protocol/keyword:
|
||||
{ "The Keyword Protocol Handler",
|
||||
NS_KEYWORDPROTOCOLHANDLER_CID,
|
||||
NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX "keyword",
|
||||
nsKeywordProtocolHandler::Create
|
||||
},
|
||||
#endif
|
||||
|
||||
#ifdef NECKO_PROTOCOL_viewsource
|
||||
// from netwerk/protocol/viewsource:
|
||||
{ "The ViewSource Protocol Handler",
|
||||
NS_VIEWSOURCEHANDLER_CID,
|
||||
NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX "view-source",
|
||||
nsViewSourceHandler::Create
|
||||
}
|
||||
#endif
|
||||
};
|
||||
|
||||
NS_IMPL_NSGETMODULE(necko_secondary_protocols, gNetModuleInfo)
|
|
@ -1,6 +1,6 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* vim:set ts=4 sw=4 sts=4 et: */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
|
@ -22,6 +22,7 @@
|
|||
*
|
||||
* Contributor(s):
|
||||
* Chak Nanga <chak@netscape.com>
|
||||
* Darin Fisher <darin@meer.net>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
|
@ -48,25 +49,11 @@
|
|||
#include "nsNetUtil.h"
|
||||
#include "nsIHttpHeaderVisitor.h"
|
||||
|
||||
// nsViewSourceChannel methods
|
||||
nsViewSourceChannel::nsViewSourceChannel() :
|
||||
mIsDocument(PR_FALSE),
|
||||
mOpened(PR_FALSE)
|
||||
{
|
||||
}
|
||||
|
||||
nsViewSourceChannel::~nsViewSourceChannel()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
NS_IMPL_THREADSAFE_ADDREF(nsViewSourceChannel)
|
||||
NS_IMPL_THREADSAFE_RELEASE(nsViewSourceChannel)
|
||||
NS_IMPL_ADDREF(nsViewSourceChannel)
|
||||
NS_IMPL_RELEASE(nsViewSourceChannel)
|
||||
/*
|
||||
This QI uses hand-expansions of NS_INTERFACE_MAP_ENTRY to check for
|
||||
This QI uses NS_INTERFACE_MAP_ENTRY_CONDITIONAL to check for
|
||||
non-nullness of mHttpChannel, mCachingChannel, and mUploadChannel.
|
||||
|
||||
This seems like a better approach than writing out the whole QI by hand.
|
||||
*/
|
||||
NS_INTERFACE_MAP_BEGIN(nsViewSourceChannel)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIViewSourceChannel)
|
||||
|
@ -87,7 +74,8 @@ nsViewSourceChannel::Init(nsIURI* uri)
|
|||
|
||||
nsCAutoString path;
|
||||
nsresult rv = uri->GetPath(path);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
nsCOMPtr<nsIIOService> pService(do_GetIOService(&rv));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
@ -104,18 +92,6 @@ nsViewSourceChannel::Init(nsIURI* uri)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_METHOD
|
||||
nsViewSourceChannel::Create(nsISupports* aOuter, const nsIID& aIID, void* *aResult)
|
||||
{
|
||||
nsViewSourceChannel* fc = new nsViewSourceChannel();
|
||||
if (fc == nsnull)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
NS_ADDREF(fc);
|
||||
nsresult rv = fc->QueryInterface(aIID, aResult);
|
||||
NS_RELEASE(fc);
|
||||
return rv;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// nsIRequest methods:
|
||||
|
||||
|
@ -684,4 +660,3 @@ nsViewSourceChannel::IsNoCacheResponse(PRBool *_retval)
|
|||
return !mHttpChannel ? NS_ERROR_NULL_POINTER :
|
||||
mHttpChannel->IsNoCacheResponse(_retval);
|
||||
}
|
||||
|
||||
|
|
|
@ -70,14 +70,11 @@ public:
|
|||
NS_FORWARD_SAFE_NSIUPLOADCHANNEL(mUploadChannel)
|
||||
|
||||
// nsViewSourceChannel methods:
|
||||
nsViewSourceChannel();
|
||||
virtual ~nsViewSourceChannel();
|
||||
nsViewSourceChannel()
|
||||
: mIsDocument(PR_FALSE)
|
||||
, mOpened(PR_FALSE) {}
|
||||
|
||||
// Define a Create method to be used with a factory:
|
||||
static NS_METHOD
|
||||
Create(nsISupports* aOuter, const nsIID& aIID, void* *aResult);
|
||||
|
||||
nsresult Init(nsIURI* uri);
|
||||
NS_HIDDEN_(nsresult) Init(nsIURI* uri);
|
||||
|
||||
protected:
|
||||
nsCOMPtr<nsIChannel> mChannel;
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim:set ts=4 sw=4 sts=4 et: */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
|
@ -21,6 +22,7 @@
|
|||
*
|
||||
* Contributor(s):
|
||||
* Chak Nanga <chak@netscape.com>
|
||||
* Darin Fisher <darin@meer.net>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
|
@ -38,90 +40,87 @@
|
|||
|
||||
#include "nsViewSourceHandler.h"
|
||||
#include "nsViewSourceChannel.h"
|
||||
#include "nsIURL.h"
|
||||
#include "nsCRT.h"
|
||||
#include "nsIComponentManager.h"
|
||||
#include "nsXPIDLString.h"
|
||||
|
||||
static NS_DEFINE_CID(kSimpleURICID, NS_SIMPLEURI_CID);
|
||||
#include "nsNetUtil.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
nsViewSourceHandler::nsViewSourceHandler() {
|
||||
}
|
||||
|
||||
nsViewSourceHandler::~nsViewSourceHandler() {
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsViewSourceHandler, nsIProtocolHandler)
|
||||
|
||||
NS_METHOD
|
||||
nsViewSourceHandler::Create(nsISupports *aOuter, REFNSIID aIID, void **aResult) {
|
||||
if (aOuter)
|
||||
return NS_ERROR_NO_AGGREGATION;
|
||||
|
||||
nsViewSourceHandler* ph = new nsViewSourceHandler();
|
||||
if (ph == nsnull)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
NS_ADDREF(ph);
|
||||
|
||||
nsresult rv = ph->QueryInterface(aIID, aResult);
|
||||
|
||||
NS_RELEASE(ph);
|
||||
return rv;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// nsIProtocolHandler methods:
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsViewSourceHandler::GetScheme(nsACString &result) {
|
||||
result = "view-source";
|
||||
nsViewSourceHandler::GetScheme(nsACString &result)
|
||||
{
|
||||
result.AssignLiteral("view-source");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsViewSourceHandler::GetDefaultPort(PRInt32 *result) {
|
||||
nsViewSourceHandler::GetDefaultPort(PRInt32 *result)
|
||||
{
|
||||
*result = -1;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsViewSourceHandler::GetProtocolFlags(PRUint32 *result) {
|
||||
nsViewSourceHandler::GetProtocolFlags(PRUint32 *result)
|
||||
{
|
||||
*result = URI_NORELATIVE | URI_NOAUTH;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsViewSourceHandler::NewURI(const nsACString &aSpec,
|
||||
const char *aCharset, // ignore charset info
|
||||
const char *aCharset,
|
||||
nsIURI *aBaseURI,
|
||||
nsIURI **result) {
|
||||
nsIURI **aResult)
|
||||
{
|
||||
nsresult rv;
|
||||
nsIURI* uri;
|
||||
|
||||
rv = nsComponentManager::CreateInstance(kSimpleURICID, nsnull, NS_GET_IID(nsIURI), (void**)&uri);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
rv = uri->SetSpec(aSpec);
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_RELEASE(uri);
|
||||
return rv;
|
||||
}
|
||||
// Extract inner URL and normalize to ASCII. This is done to properly
|
||||
// support IDN in cases like "view-source:http://www.szalagavató.hu/"
|
||||
|
||||
*result = uri;
|
||||
PRInt32 colon = aSpec.FindChar(':');
|
||||
if (colon == kNotFound)
|
||||
return NS_ERROR_MALFORMED_URI;
|
||||
|
||||
nsCOMPtr<nsIURI> innerURI;
|
||||
rv = NS_NewURI(getter_AddRefs(innerURI), Substring(aSpec, colon + 1), aCharset);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
nsCAutoString asciiSpec;
|
||||
rv = innerURI->GetAsciiSpec(asciiSpec);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
// put back our scheme and construct a simple-uri wrapper
|
||||
|
||||
asciiSpec.Insert("view-source:", 0);
|
||||
|
||||
nsIURI *uri;
|
||||
rv = CallCreateInstance(NS_SIMPLEURI_CONTRACTID, nsnull, &uri);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
rv = uri->SetSpec(asciiSpec);
|
||||
if (NS_FAILED(rv))
|
||||
NS_RELEASE(uri);
|
||||
else
|
||||
*aResult = uri;
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsViewSourceHandler::NewChannel(nsIURI* uri, nsIChannel* *result)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
nsViewSourceChannel* channel;
|
||||
rv = nsViewSourceChannel::Create(nsnull, NS_GET_IID(nsIChannel), (void**)&channel);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
nsViewSourceChannel *channel = new nsViewSourceChannel();
|
||||
if (!channel)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
NS_ADDREF(channel);
|
||||
|
||||
rv = channel->Init(uri);
|
||||
nsresult rv = channel->Init(uri);
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_RELEASE(channel);
|
||||
return rv;
|
||||
|
@ -138,5 +137,3 @@ nsViewSourceHandler::AllowPort(PRInt32 port, const char *scheme, PRBool *_retval
|
|||
*_retval = PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -40,28 +40,12 @@
|
|||
#define nsViewSourceHandler_h___
|
||||
|
||||
#include "nsIProtocolHandler.h"
|
||||
#include "nsString.h"
|
||||
|
||||
// {0x9c7ec5d1-23f9-11d5-aea8-8fcc0793e97f}
|
||||
#define NS_VIEWSOURCEHANDLER_CID \
|
||||
{ 0x9c7ec5d1, 0x23f9, 0x11d5, \
|
||||
{ 0xae, 0xa8, 0x8f, 0xcc, 0x7, 0x93, 0xe9, 0x7f } }
|
||||
|
||||
class nsViewSourceHandler : public nsIProtocolHandler
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIPROTOCOLHANDLER
|
||||
|
||||
// nsViewSourceHandler methods:
|
||||
nsViewSourceHandler();
|
||||
virtual ~nsViewSourceHandler();
|
||||
|
||||
// Define a Create method to be used with a factory:
|
||||
static NS_METHOD Create(nsISupports* aOuter, const nsIID& aIID, void* *aResult);
|
||||
|
||||
nsresult Init();
|
||||
|
||||
};
|
||||
|
||||
#endif /* nsViewSourceHandler_h___ */
|
||||
#endif /* !defined( nsViewSourceHandler_h___ ) */
|
||||
|
|
Загрузка…
Ссылка в новой задаче