зеркало из https://github.com/mozilla/pjs.git
Bug 372554 - "ASSERTION: cannot set host on no-auth url" trying to set location.hostname at a file: URL
p=Ryan Jones <sciguyryan@gmail.com> r=biesi/r+sr=jst
This commit is contained in:
Родитель
cc08284199
Коммит
d6e3c1b3e2
|
@ -57,7 +57,6 @@
|
||||||
#include "nsCOMPtr.h"
|
#include "nsCOMPtr.h"
|
||||||
#include "nsEscape.h"
|
#include "nsEscape.h"
|
||||||
#include "nsJSUtils.h"
|
#include "nsJSUtils.h"
|
||||||
#include "nsIScriptSecurityManager.h"
|
|
||||||
#include "nsIDOMWindow.h"
|
#include "nsIDOMWindow.h"
|
||||||
#include "nsIDOMDocument.h"
|
#include "nsIDOMDocument.h"
|
||||||
#include "nsIDocument.h"
|
#include "nsIDocument.h"
|
||||||
|
@ -428,18 +427,17 @@ NS_IMETHODIMP
|
||||||
nsLocation::SetHash(const nsAString& aHash)
|
nsLocation::SetHash(const nsAString& aHash)
|
||||||
{
|
{
|
||||||
nsCOMPtr<nsIURI> uri;
|
nsCOMPtr<nsIURI> uri;
|
||||||
nsresult result = NS_OK;
|
nsresult rv = GetWritableURI(getter_AddRefs(uri));
|
||||||
|
|
||||||
result = GetWritableURI(getter_AddRefs(uri));
|
|
||||||
|
|
||||||
nsCOMPtr<nsIURL> url(do_QueryInterface(uri));
|
nsCOMPtr<nsIURL> url(do_QueryInterface(uri));
|
||||||
|
|
||||||
if (url) {
|
if (url) {
|
||||||
url->SetRef(NS_ConvertUTF16toUTF8(aHash));
|
rv = url->SetRef(NS_ConvertUTF16toUTF8(aHash));
|
||||||
SetURI(url);
|
if (NS_SUCCEEDED(rv)) {
|
||||||
|
SetURI(url);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
|
@ -469,16 +467,16 @@ NS_IMETHODIMP
|
||||||
nsLocation::SetHost(const nsAString& aHost)
|
nsLocation::SetHost(const nsAString& aHost)
|
||||||
{
|
{
|
||||||
nsCOMPtr<nsIURI> uri;
|
nsCOMPtr<nsIURI> uri;
|
||||||
nsresult result;
|
nsresult rv = GetWritableURI(getter_AddRefs(uri));
|
||||||
|
|
||||||
result = GetWritableURI(getter_AddRefs(uri));
|
|
||||||
|
|
||||||
if (uri) {
|
if (uri) {
|
||||||
uri->SetHostPort(NS_ConvertUTF16toUTF8(aHost));
|
rv = uri->SetHostPort(NS_ConvertUTF16toUTF8(aHost));
|
||||||
SetURI(uri);
|
if (NS_SUCCEEDED(rv)) {
|
||||||
|
SetURI(uri);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
|
@ -508,16 +506,16 @@ NS_IMETHODIMP
|
||||||
nsLocation::SetHostname(const nsAString& aHostname)
|
nsLocation::SetHostname(const nsAString& aHostname)
|
||||||
{
|
{
|
||||||
nsCOMPtr<nsIURI> uri;
|
nsCOMPtr<nsIURI> uri;
|
||||||
nsresult result;
|
nsresult rv = GetWritableURI(getter_AddRefs(uri));
|
||||||
|
|
||||||
result = GetWritableURI(getter_AddRefs(uri));
|
|
||||||
|
|
||||||
if (uri) {
|
if (uri) {
|
||||||
uri->SetHost(NS_ConvertUTF16toUTF8(aHostname));
|
rv = uri->SetHost(NS_ConvertUTF16toUTF8(aHostname));
|
||||||
SetURI(uri);
|
if (NS_SUCCEEDED(rv)) {
|
||||||
|
SetURI(uri);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
|
@ -687,16 +685,16 @@ NS_IMETHODIMP
|
||||||
nsLocation::SetPathname(const nsAString& aPathname)
|
nsLocation::SetPathname(const nsAString& aPathname)
|
||||||
{
|
{
|
||||||
nsCOMPtr<nsIURI> uri;
|
nsCOMPtr<nsIURI> uri;
|
||||||
nsresult result = NS_OK;
|
nsresult rv = GetWritableURI(getter_AddRefs(uri));
|
||||||
|
|
||||||
result = GetWritableURI(getter_AddRefs(uri));
|
|
||||||
|
|
||||||
if (uri) {
|
if (uri) {
|
||||||
uri->SetPath(NS_ConvertUTF16toUTF8(aPathname));
|
rv = uri->SetPath(NS_ConvertUTF16toUTF8(aPathname));
|
||||||
SetURI(uri);
|
if (NS_SUCCEEDED(rv)) {
|
||||||
|
SetURI(uri);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
|
@ -730,9 +728,7 @@ NS_IMETHODIMP
|
||||||
nsLocation::SetPort(const nsAString& aPort)
|
nsLocation::SetPort(const nsAString& aPort)
|
||||||
{
|
{
|
||||||
nsCOMPtr<nsIURI> uri;
|
nsCOMPtr<nsIURI> uri;
|
||||||
nsresult result = NS_OK;
|
nsresult rv = GetWritableURI(getter_AddRefs(uri));
|
||||||
|
|
||||||
result = GetWritableURI(getter_AddRefs(uri));
|
|
||||||
|
|
||||||
if (uri) {
|
if (uri) {
|
||||||
// perhaps use nsReadingIterators at some point?
|
// perhaps use nsReadingIterators at some point?
|
||||||
|
@ -749,11 +745,13 @@ nsLocation::SetPort(const nsAString& aPort)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
uri->SetPort(port);
|
rv = uri->SetPort(port);
|
||||||
SetURI(uri);
|
if (NS_SUCCEEDED(rv)) {
|
||||||
|
SetURI(uri);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
|
@ -784,16 +782,16 @@ NS_IMETHODIMP
|
||||||
nsLocation::SetProtocol(const nsAString& aProtocol)
|
nsLocation::SetProtocol(const nsAString& aProtocol)
|
||||||
{
|
{
|
||||||
nsCOMPtr<nsIURI> uri;
|
nsCOMPtr<nsIURI> uri;
|
||||||
nsresult result = NS_OK;
|
nsresult rv = GetWritableURI(getter_AddRefs(uri));
|
||||||
|
|
||||||
result = GetWritableURI(getter_AddRefs(uri));
|
|
||||||
|
|
||||||
if (uri) {
|
if (uri) {
|
||||||
uri->SetScheme(NS_ConvertUTF16toUTF8(aProtocol));
|
rv = uri->SetScheme(NS_ConvertUTF16toUTF8(aProtocol));
|
||||||
SetURI(uri);
|
if (NS_SUCCEEDED(rv)) {
|
||||||
|
SetURI(uri);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
|
@ -826,17 +824,17 @@ NS_IMETHODIMP
|
||||||
nsLocation::SetSearch(const nsAString& aSearch)
|
nsLocation::SetSearch(const nsAString& aSearch)
|
||||||
{
|
{
|
||||||
nsCOMPtr<nsIURI> uri;
|
nsCOMPtr<nsIURI> uri;
|
||||||
nsresult result = NS_OK;
|
nsresult rv = GetWritableURI(getter_AddRefs(uri));
|
||||||
|
|
||||||
result = GetWritableURI(getter_AddRefs(uri));
|
|
||||||
|
|
||||||
nsCOMPtr<nsIURL> url(do_QueryInterface(uri));
|
nsCOMPtr<nsIURL> url(do_QueryInterface(uri));
|
||||||
if (url) {
|
if (url) {
|
||||||
result = url->SetQuery(NS_ConvertUTF16toUTF8(aSearch));
|
rv = url->SetQuery(NS_ConvertUTF16toUTF8(aSearch));
|
||||||
SetURI(uri);
|
if (NS_SUCCEEDED(rv)) {
|
||||||
|
SetURI(uri);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
|
|
|
@ -1425,7 +1425,7 @@ nsStandardURL::SetHost(const nsACString &input)
|
||||||
if (mURLType == URLTYPE_NO_AUTHORITY) {
|
if (mURLType == URLTYPE_NO_AUTHORITY) {
|
||||||
if (flat.IsEmpty())
|
if (flat.IsEmpty())
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
NS_ERROR("cannot set host on no-auth url");
|
NS_WARNING("cannot set host on no-auth url");
|
||||||
return NS_ERROR_UNEXPECTED;
|
return NS_ERROR_UNEXPECTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1499,7 +1499,7 @@ nsStandardURL::SetPort(PRInt32 port)
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
|
|
||||||
if (mURLType == URLTYPE_NO_AUTHORITY) {
|
if (mURLType == URLTYPE_NO_AUTHORITY) {
|
||||||
NS_ERROR("cannot set port on no-auth url");
|
NS_WARNING("cannot set port on no-auth url");
|
||||||
return NS_ERROR_UNEXPECTED;
|
return NS_ERROR_UNEXPECTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче