/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
// It is valid for docshell to return a null URI. Don't try to fixup // if this happens. if (!uri) { return NS_OK;
}
if (aGetInnermostURI) {
nsCOMPtr<nsIJARURI> jarURI(do_QueryInterface(uri)); while (jarURI) {
jarURI->GetJARFile(getter_AddRefs(uri));
jarURI = do_QueryInterface(uri);
}
}
NS_ASSERTION(uri, "nsJARURI screwed up?");
// Remove the fragment directive from the url hash.
FragmentDirective::ParseAndRemoveFragmentDirectiveFromFragment(uri);
nsCOMPtr<nsIURI> exposableURI = net::nsIOService::CreateExposableURI(uri);
exposableURI.forget(aURI); return NS_OK;
}
nsCOMPtr<nsIURI> uri;
aRv = GetURI(getter_AddRefs(uri)); if (NS_WARN_IF(aRv.Failed() || !uri)) { return;
}
// perhaps use nsReadingIterators at some point?
nsAutoCString portStr(aPort); constchar* buf = portStr.get();
int32_t port = -1;
if (!portStr.IsEmpty() && buf) { // Sadly, ToInteger() on nsACString does not have the right semantics. if (*buf == ':') {
port = atol(buf + 1);
} else {
port = atol(buf);
}
}
aRv = NS_MutateURI(uri).SetPort(port).Finalize(uri); if (NS_WARN_IF(aRv.Failed())) { return;
}
nsresult rv =
NS_MutateURI(uri).SetScheme(Substring(start, iter)).Finalize(uri); if (NS_WARN_IF(NS_FAILED(rv))) { // Oh, I wish nsStandardURL returned NS_ERROR_MALFORMED_URI for _all_ the // malformed cases, not just some of them!
aRv.Throw(NS_ERROR_DOM_SYNTAX_ERR); return;
}
nsAutoCString newSpec;
aRv = uri->GetSpec(newSpec); if (NS_WARN_IF(aRv.Failed())) { return;
} // We may want a new URI class for the new URI, so recreate it:
rv = NS_NewURI(getter_AddRefs(uri), newSpec); if (NS_FAILED(rv)) { if (rv == NS_ERROR_MALFORMED_URI) {
rv = NS_ERROR_DOM_SYNTAX_ERR;
}
aRv.Throw(rv); return;
}
if (!uri->SchemeIs("http") && !uri->SchemeIs("https")) { // No-op, per spec. return;
}
if (aForceget) {
reloadFlags = nsIWebNavigation::LOAD_FLAGS_BYPASS_CACHE |
nsIWebNavigation::LOAD_FLAGS_BYPASS_PROXY;
}
rv = docShell->Reload(reloadFlags); if (NS_FAILED(rv) && rv != NS_BINDING_ABORTED) { // NS_BINDING_ABORTED is returned when we attempt to reload a POST result // and the user says no at the "do you want to reload?" prompt. Don't // propagate this one back to callers. return aRv.Throw(rv);
}
}
BrowsingContext* bc = GetBrowsingContext(); if (MOZ_UNLIKELY(!bc) || MOZ_UNLIKELY(bc->IsDiscarded())) { // Per spec, operations on a Location object with a discarded BC are no-ops, // not security errors, so we need to return true from the access check and // let the caller do its own discarded docShell check. returntrue;
} if (MOZ_UNLIKELY(!bc->IsInProcess())) { returnfalse;
}
// Get the principal associated with the location object. Note that this is // the principal of the page which will actually be navigated, not the // principal of the Location object itself. This is why we need this check // even though we only allow limited cross-origin access to Location objects // in general.
nsPIDOMWindowOuter* outer = bc->GetDOMWindow();
MOZ_DIAGNOSTIC_ASSERT(outer); if (MOZ_UNLIKELY(!outer)) returnfalse;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.