--- a/browser/confvars.sh
+++ b/browser/confvars.sh
@@ -23,20 +23,16 @@ if test "$OS_ARCH" = "WINNT"; then
"$MOZ_UPDATE_CHANNEL" = "release"; then
if ! test "$MOZ_DEBUG"; then
MOZ_STUB_INSTALLER=1
fi
fi
fi
fi
-if test "$NIGHTLY_BUILD"; then
- MOZ_RUST_URLPARSE=1
-fi
-
# Enable building ./signmar and running libmar signature tests
MOZ_ENABLE_SIGNMAR=1
MOZ_APP_VERSION=$FIREFOX_VERSION
MOZ_APP_VERSION_DISPLAY=$FIREFOX_VERSION_DISPLAY
# MOZ_APP_DISPLAYNAME will be set by branding/configure.sh
# MOZ_BRANDING_DIRECTORY is the default branding directory used when none is
# specified. It should never point to the "official" branding directory.
--- a/modules/libpref/init/all.js
+++ b/modules/libpref/init/all.js
@@ -2094,20 +2094,16 @@ pref("network.dns.localDomains", "");
pref("network.dns.forceResolve", "");
// Contols whether or not "localhost" should resolve when offline
pref("network.dns.offline-localhost", true);
// The maximum allowed length for a URL - 1MB default
pref("network.standard-url.max-length", 1048576);
-// The preference controls if the rust URL parser is run in parallel with the
-// C++ implementation. Requires restart for changes to take effect.
-pref("network.standard-url.enable-rust", false);
-
// Whether nsIURI.host/.hostname/.spec should return a punycode string
// If set to false we will revert to previous behaviour and return a unicode string.
pref("network.standard-url.punycode-host", true);
// Idle timeout for ftp control connections - 5 minute default
pref("network.ftp.idleConnectionTimeout", 300);
// directory listing format
deleted file mode 100644
--- a/netwerk/base/RustURL.cpp
+++ /dev/null
@@ -1,759 +0,0 @@
-#include "RustURL.h"
-#include "nsCOMPtr.h"
-#include "nsURLHelper.h"
-
-#ifndef MOZ_RUST_URLPARSE
- #error "Should be defined"
-#endif
-
-using namespace mozilla::ipc;
-
-namespace mozilla {
-namespace net {
-
-NS_IMPL_ADDREF(RustURL)
-NS_IMPL_RELEASE(RustURL)
-
-NS_INTERFACE_MAP_BEGIN(RustURL)
- NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIStandardURL)
- NS_INTERFACE_MAP_ENTRY(nsIURI)
- NS_INTERFACE_MAP_ENTRY(nsIURL)
- // NS_INTERFACE_MAP_ENTRY_CONDITIONAL(nsIFileURL, mSupportsFileURL)
- NS_INTERFACE_MAP_ENTRY(nsIStandardURL)
- // NS_INTERFACE_MAP_ENTRY(nsISerializable)
- NS_INTERFACE_MAP_ENTRY(nsIClassInfo)
- NS_INTERFACE_MAP_ENTRY(nsIMutable)
- // NS_INTERFACE_MAP_ENTRY(nsIIPCSerializableURI)
- // NS_INTERFACE_MAP_ENTRY(nsISensitiveInfoHiddenURI)
- NS_INTERFACE_MAP_ENTRY(nsISizeOf)
-NS_INTERFACE_MAP_END
-
-#define ENSURE_MUTABLE() \
- PR_BEGIN_MACRO \
- if (!mMutable) { \
- NS_WARNING("attempt to modify an immutable RustURL"); \
- return NS_ERROR_ABORT; \
- } \
- PR_END_MACRO
-
-RustURL::RustURL()
- : mMutable(true)
-{
-
-}
-
-RustURL::~RustURL()
-{
-
-}
-
-NS_IMETHODIMP
-RustURL::GetSpec(nsACString & aSpec)
-{
- return rusturl_get_spec(mURL.get(), &aSpec);
-}
-
-NS_IMETHODIMP
-RustURL::SetSpec(const nsACString & aSpec)
-{
- ENSURE_MUTABLE();
-
- rusturl* ptr = rusturl_new(&aSpec, nullptr);
- if (!ptr) {
- return NS_ERROR_FAILURE;
- }
- mURL.reset(ptr);
- return NS_OK;
-}
-
-NS_IMETHODIMP
-RustURL::GetPrePath(nsACString & aPrePath)
-{
- // TODO: use slicing API to get actual prepath
- aPrePath.Truncate();
- nsAutoCString rustResult;
- nsAutoCString part;
-
- nsresult rv = GetScheme(part);
- if (NS_FAILED(rv)) {
- return rv;
- }
- rustResult.Append(part);
- rustResult += "://";
-
- rv = GetUserPass(part);
- if (NS_FAILED(rv)) {
- return rv;
- }
- if (!part.IsEmpty()) {
- rustResult += part;
- rustResult += "@";
- }
-
- rv = GetHostPort(part);
- if (NS_FAILED(rv)) {
- return rv;
- }
-
- rustResult += part;
- aPrePath.Assign(rustResult);
- return NS_OK;
-}
-
-NS_IMETHODIMP
-RustURL::GetScheme(nsACString & aScheme)
-{
- return rusturl_get_scheme(mURL.get(), &aScheme);
-}
-
-NS_IMETHODIMP
-RustURL::SetScheme(const nsACString & aScheme)
-{
- ENSURE_MUTABLE();
-
- return rusturl_set_scheme(mURL.get(), &aScheme);
-}
-
-NS_IMETHODIMP
-RustURL::GetUserPass(nsACString & aUserPass)
-{
- nsresult rv = GetUsername(aUserPass);
- if (NS_FAILED(rv)) {
- aUserPass.Truncate();
- return rv;
- }
-
- nsAutoCString password;
- rv = GetPassword(password);
- if (NS_FAILED(rv)) {
- aUserPass.Truncate();
- return rv;
- }
-
- if (password.Length()) {
- aUserPass.Append(':');
- aUserPass.Append(password);
- }
- return NS_OK;
-}
-
-NS_IMETHODIMP
-RustURL::SetUserPass(const nsACString & aUserPass)
-{
- ENSURE_MUTABLE();
-
- int32_t colonPos = aUserPass.FindChar(':');
- nsAutoCString user;
- nsAutoCString pass;
- if (colonPos == kNotFound) {
- user = aUserPass;
- } else {
- user = Substring(aUserPass, 0, colonPos);
- pass = Substring(aUserPass, colonPos + 1, aUserPass.Length());
- }
-
- nsresult rv = rusturl_set_username(mURL.get(), &user);
- if (NS_WARN_IF(NS_FAILED(rv))) {
- return rv;
- }
-
- return rusturl_set_password(mURL.get(), &pass);
-}
-
-NS_IMETHODIMP
-RustURL::GetUsername(nsACString & aUsername)
-{
- return rusturl_get_username(mURL.get(), &aUsername);
-}
-
-NS_IMETHODIMP
-RustURL::SetUsername(const nsACString & aUsername)
-{
- ENSURE_MUTABLE();
- return rusturl_set_username(mURL.get(), &aUsername);
-}
-
-NS_IMETHODIMP
-RustURL::GetPassword(nsACString & aPassword)
-{
- return rusturl_get_password(mURL.get(), &aPassword);
-}
-
-NS_IMETHODIMP
-RustURL::SetPassword(const nsACString & aPassword)
-{
- ENSURE_MUTABLE();
- return rusturl_set_password(mURL.get(), &aPassword);
-}
-
-NS_IMETHODIMP
-RustURL::GetHostPort(nsACString & aHostPort)
-{
- nsresult rv = rusturl_get_host(mURL.get(), &aHostPort);
- if (NS_FAILED(rv)) {
- return rv;
- }
-
- int32_t port;
- rv = GetPort(&port);
- if (NS_FAILED(rv)) {
- return rv;
- }
- if (port >= 0) {
- aHostPort.Append(':');
- aHostPort.AppendInt(port);
- }
-
- return NS_OK;
-}
-
-NS_IMETHODIMP
-RustURL::SetHostPort(const nsACString & aHostPort)
-{
- ENSURE_MUTABLE();
- return rusturl_set_host_port(mURL.get(), &aHostPort);
-}
-
-NS_IMETHODIMP
-RustURL::SetHostAndPort(const nsACString & hostport)
-{
- ENSURE_MUTABLE();
- return rusturl_set_host_and_port(mURL.get(), &hostport);
-}
-
-NS_IMETHODIMP
-RustURL::GetHost(nsACString & aHost)
-{
- nsAutoCString host;
- nsresult rv = rusturl_get_host(mURL.get(), &host);
- if (NS_FAILED(rv)) {
- return rv;
- }
-
- if (host.Length() > 0 && host.First() == '[' && host.Last() == ']') {
- aHost = Substring(host, 1, host.Length() - 2);
- return NS_OK;
- }
-
- aHost = host;
- return NS_OK;
-}
-
-NS_IMETHODIMP
-RustURL::SetHost(const nsACString & aHost)
-{
- ENSURE_MUTABLE();
- return rusturl_set_host(mURL.get(), &aHost);
-}
-
-NS_IMETHODIMP
-RustURL::GetPort(int32_t *aPort)
-{
- if (!mURL) {
- return NS_ERROR_FAILURE;
- }
- *aPort = 0;
- return rusturl_get_port(mURL.get(), aPort);
-}
-
-NS_IMETHODIMP
-RustURL::SetPort(int32_t aPort)
-{
- ENSURE_MUTABLE();
- return rusturl_set_port_no(mURL.get(), aPort);
-}
-
-NS_IMETHODIMP
-RustURL::GetPathQueryRef(nsACString & aPath)
-{
- return rusturl_get_path(mURL.get(), &aPath);
-}
-
-NS_IMETHODIMP
-RustURL::SetPathQueryRef(const nsACString & aPath)
-{
- ENSURE_MUTABLE();
-
- nsAutoCString path;
- nsresult rv = GetPrePath(path);
- if (NS_FAILED(rv)) {
- return rv;
- }
-
- if (aPath.Length() > 0 && aPath.First() != '/') {
- path.Append('/');
- }
- path.Append(aPath);
-
- return SetSpec(path);
-}
-
-NS_IMETHODIMP
-RustURL::Equals(nsIURI *other, bool *aRetVal)
-{
- *aRetVal = false;
- nsAutoCString spec;
- nsresult rv = other->GetSpec(spec);
- if (NS_FAILED(rv)) {
- return rv;
- }
- nsAutoCString rustSpec;
- rv = GetSpec(rustSpec);
- if (NS_FAILED(rv)) {
- return rv;
- }
- if (rustSpec == spec) {
- *aRetVal = true;
- }
- return NS_OK;
-}
-
-NS_IMETHODIMP
-RustURL::SchemeIs(const char * aScheme, bool *aRetVal)
-{
- *aRetVal = false;
- nsAutoCString scheme;
- nsresult rv = GetScheme(scheme);
- if (NS_FAILED(rv)) {
- return rv;
- }
- if (scheme.Equals(aScheme, nsCaseInsensitiveCStringComparator())) {
- *aRetVal = true;
- }
- return NS_OK;
-}
-
-NS_IMETHODIMP
-RustURL::Clone(nsIURI * *aRetVal)
-{
- RefPtr<RustURL> url = new RustURL();
- nsAutoCString spec;
- nsresult rv = GetSpec(spec);
- if (NS_FAILED(rv)) {
- return rv;
- }
- rv = url->SetSpec(spec);
- if (NS_FAILED(rv)) {
- return rv;
- }
- url.forget(aRetVal);
- return NS_OK;
-}
-
-NS_IMETHODIMP
-RustURL::Resolve(const nsACString & relativePath, nsACString & aRetVal)
-{
- return rusturl_resolve(mURL.get(), &relativePath, &aRetVal);
-}
-
-NS_IMETHODIMP
-RustURL::GetAsciiSpec(nsACString & aAsciiSpec)
-{
- return GetSpec(aAsciiSpec);
-}
-
-NS_IMETHODIMP
-RustURL::GetAsciiHostPort(nsACString & aAsciiHostPort)
-{
- return GetHostPort(aAsciiHostPort);
-}
-
-NS_IMETHODIMP
-RustURL::GetAsciiHost(nsACString & aAsciiHost)
-{
- return GetHost(aAsciiHost);
-}
-
-NS_IMETHODIMP
-RustURL::GetRef(nsACString & aRef)
-{
- return rusturl_get_fragment(mURL.get(), &aRef);
-}
-
-NS_IMETHODIMP
-RustURL::SetRef(const nsACString & aRef)
-{
- ENSURE_MUTABLE();
- return rusturl_set_fragment(mURL.get(), &aRef);
-}
-
-NS_IMETHODIMP
-RustURL::EqualsExceptRef(nsIURI *other, bool *_retval)
-{
- *_retval = false;
- nsAutoCString otherSpec;
- nsresult rv = other->GetSpecIgnoringRef(otherSpec);
- if (NS_FAILED(rv)) {
- return rv;
- }
- nsAutoCString thisSpec;
- rv = GetSpecIgnoringRef(thisSpec);
- if (NS_FAILED(rv)) {
- return rv;
- }
- if (thisSpec == otherSpec) {
- *_retval = true;
- }
- return NS_OK;
-}
-
-NS_IMETHODIMP
-RustURL::CloneIgnoringRef(nsIURI * *_retval)
-{
- return CloneWithNewRef(NS_LITERAL_CSTRING(""), _retval);
-}
-
-NS_IMETHODIMP
-RustURL::CloneWithNewRef(const nsACString & newRef, nsIURI * *_retval)
-{
- nsCOMPtr<nsIURI> uri;
- nsresult rv = Clone(getter_AddRefs(uri));
- if (NS_FAILED(rv)) {
- return rv;
- }
- rv = uri->SetRef(newRef);
- if (NS_FAILED(rv)) {
- return rv;
- }
- uri.forget(_retval);
- return NS_OK;
-}
-
-NS_IMETHODIMP
-RustURL::GetSpecIgnoringRef(nsACString & aSpecIgnoringRef)
-{
- nsresult rv = GetSpec(aSpecIgnoringRef);
- if (NS_FAILED(rv)) {
- return rv;
- }
- int32_t pos = aSpecIgnoringRef.FindChar('#');
- if (pos == kNotFound) {
- return NS_OK;
- }
-
- aSpecIgnoringRef.Truncate(pos);
- return NS_OK;
-}
-
-NS_IMETHODIMP
-RustURL::GetDisplaySpec(nsACString &aUnicodeSpec)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP
-RustURL::GetDisplayHostPort(nsACString &aUnicodeHostPort)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP
-RustURL::GetDisplayHost(nsACString &aUnicodeHost)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP
-RustURL::GetDisplayPrePath(nsACString & aPrePath)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP
-RustURL::GetHasRef(bool *aHasRef)
-{
- *aHasRef = false;
- return rusturl_has_fragment(mURL.get(), aHasRef);
-}
-
-/// nsIURL
-
-NS_IMETHODIMP
-RustURL::GetFilePath(nsACString & aFilePath)
-{
- return rusturl_get_path(mURL.get(), &aFilePath);
-}
-
-NS_IMETHODIMP
-RustURL::SetFilePath(const nsACString & aFilePath)
-{
- ENSURE_MUTABLE();
- return rusturl_set_path(mURL.get(), &aFilePath);
-}
-
-NS_IMETHODIMP
-RustURL::GetQuery(nsACString & aQuery)
-{
- return rusturl_get_query(mURL.get(), &aQuery);
-}
-
-NS_IMETHODIMP
-RustURL::SetQuery(const nsACString & aQuery)
-{
- ENSURE_MUTABLE();
- return rusturl_set_query(mURL.get(), &aQuery);
-}
-
-NS_IMETHODIMP
-RustURL::SetQueryWithEncoding(const nsACString& aQuery,
- const Encoding* aEncoding)
-{
- ENSURE_MUTABLE();
- //XXX rust-url-capi should support the concept of "encoding override"
- return rusturl_set_query(mURL.get(), &aQuery);
-}
-
-NS_IMETHODIMP
-RustURL::GetDirectory(nsACString & aDirectory)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP
-RustURL::SetDirectory(const nsACString & aDirectory)
-{
- ENSURE_MUTABLE();
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP
-RustURL::GetFileName(nsACString & aFileName)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP
-RustURL::SetFileName(const nsACString & aFileName)
-{
- ENSURE_MUTABLE();
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP
-RustURL::GetFileBaseName(nsACString & aFileBaseName)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP
-RustURL::SetFileBaseName(const nsACString & aFileBaseName)
-{
- ENSURE_MUTABLE();
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP
-RustURL::GetFileExtension(nsACString & aFileExtension)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP
-RustURL::SetFileExtension(const nsACString & aFileExtension)
-{
- ENSURE_MUTABLE();
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP
-RustURL::GetCommonBaseSpec(nsIURI *aURIToCompare, nsACString & _retval)
-{
- RefPtr<RustURL> url = new RustURL();
- nsAutoCString spec;
- nsresult rv = aURIToCompare->GetSpec(spec);
- if (NS_FAILED(rv)) {
- return rv;
- }
- rv = url->SetSpec(spec);
- if (NS_FAILED(rv)) {
- return rv;
- }
- return rusturl_common_base_spec(mURL.get(), url->mURL.get(), &_retval);
-}
-
-NS_IMETHODIMP
-RustURL::GetRelativeSpec(nsIURI *aURIToCompare, nsACString & _retval)
-{
- RefPtr<RustURL> url = new RustURL();
- nsAutoCString spec;
- nsresult rv = aURIToCompare->GetSpec(spec);
- if (NS_FAILED(rv)) {
- return rv;
- }
- rv = url->SetSpec(spec);
- if (NS_FAILED(rv)) {
- return rv;
- }
-
- return rusturl_relative_spec(mURL.get(), url->mURL.get(), &_retval);
-}
-
-// nsIFileURL
-
-
-NS_IMETHODIMP
-RustURL::GetFile(nsIFile * *aFile)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP
-RustURL::SetFile(nsIFile *aFile)
-{
- ENSURE_MUTABLE();
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-// nsIStandardURL
-
-NS_IMETHODIMP
-RustURL::Init(uint32_t aUrlType, int32_t aDefaultPort, const nsACString & aSpec,
- const char * aOriginCharset, nsIURI *aBaseURI)
-{
- ENSURE_MUTABLE();
-
- if (aBaseURI && net_IsAbsoluteURL(aSpec)) {
- aBaseURI = nullptr;
- }
-
- if (!aBaseURI) {
- return SetSpec(aSpec);
- }
-
- nsAutoCString buf;
- nsresult rv = aBaseURI->Resolve(aSpec, buf);
- if (NS_FAILED(rv)) {
- return rv;
- }
-
- return SetSpec(buf);
-}
-
-NS_IMETHODIMP
-RustURL::SetDefaultPort(int32_t aNewDefaultPort)
-{
- ENSURE_MUTABLE();
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-// nsISerializable
-
-NS_IMETHODIMP
-RustURL::Read(nsIObjectInputStream *aInputStream)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP
-RustURL::Write(nsIObjectOutputStream *aOutputStream)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-void
-RustURL::Serialize(URIParams& aParams)
-{
- // TODO
-}
-
-bool
-RustURL::Deserialize(const URIParams& aParams)
-{
- // TODO
- return false;
-}
-
-// nsIClassInfo
-
-NS_IMETHODIMP
-RustURL::GetInterfaces(uint32_t *count, nsIID ***array)
-{
- *count = 0;
- *array = nullptr;
- return NS_OK;
-}
-
-NS_IMETHODIMP
-RustURL::GetScriptableHelper(nsIXPCScriptable * *_retval)
-{
- *_retval = nullptr;
- return NS_OK;
-}
-
-NS_IMETHODIMP
-RustURL::GetContractID(nsACString& aContractID)
-{
- aContractID.SetIsVoid(true);
- return NS_OK;
-}
-
-NS_IMETHODIMP
-RustURL::GetClassDescription(nsACString& aClassDescription)
-{
- aClassDescription.SetIsVoid(true);
- return NS_OK;
-}
-
-NS_IMETHODIMP
-RustURL::GetClassID(nsCID **aClassID)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-NS_IMETHODIMP
-RustURL::GetFlags(uint32_t *aFlags)
-{
- *aFlags = nsIClassInfo::MAIN_THREAD_ONLY;
- return NS_OK;
-}
-
-NS_IMETHODIMP
-RustURL::GetClassIDNoAlloc(nsCID *aClassIDNoAlloc)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-/// nsIMutable
-
-NS_IMETHODIMP
-RustURL::GetMutable(bool *aValue)
-{
- *aValue = mMutable;
- return NS_OK;
-}
-
-NS_IMETHODIMP
-RustURL::SetMutable(bool aValue)
-{
- if (mMutable || !aValue) {
- return NS_ERROR_FAILURE;
- }
- mMutable = aValue;
- return NS_OK;
-}
-
-// nsISensitiveInfoHiddenURI
-
-NS_IMETHODIMP
-RustURL::GetSensitiveInfoHiddenSpec(nsACString & _retval)
-{
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-// nsISizeOf
-
-size_t
-RustURL::SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const
-{
- return mURL.get() ? sizeof_rusturl() : 0;
-}
-
-size_t
-RustURL::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const
-{
- return aMallocSizeOf(this) + SizeOfExcludingThis(aMallocSizeOf);
-}
-
-} // namespace net
-} // namespace mozilla
-
deleted file mode 100644
--- a/netwerk/base/RustURL.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* 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/. */
-
-#ifndef RustURL_h__
-#define RustURL_h__
-
-#include "nsISerializable.h"
-#include "nsIFileURL.h"
-#include "nsIStandardURL.h"
-#include "nsIClassInfo.h"
-#include "nsISizeOf.h"
-#include "nsIIPCSerializableURI.h"
-#include "nsISensitiveInfoHiddenURI.h"
-
-#include "rust-url-capi/src/rust-url-capi.h"
-#include "mozilla/UniquePtr.h"
-
-namespace mozilla {
-namespace net {
-
-class RustURL final
- : public nsIFileURL
- , public nsIStandardURL
- , public nsISerializable
- , public nsIClassInfo
- , public nsISizeOf
- , public nsIIPCSerializableURI
- , public nsISensitiveInfoHiddenURI
-{
- NS_DECL_ISUPPORTS
- NS_DECL_NSIURI
- NS_DECL_NSIURL
- NS_DECL_NSIFILEURL
- NS_DECL_NSISTANDARDURL
- NS_DECL_NSISERIALIZABLE
- NS_DECL_NSICLASSINFO
- NS_DECL_NSIMUTABLE
- NS_DECL_NSIIPCSERIALIZABLEURI
- NS_DECL_NSISENSITIVEINFOHIDDENURI
-
- RustURL();
- // nsISizeOf
- virtual size_t SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const override;
- virtual size_t SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const override;
-private:
- virtual ~RustURL();
-
- struct FreeRustURL { void operator()(rusturl* aPtr) { rusturl_free(aPtr); } };
- mutable mozilla::UniquePtr<rusturl, FreeRustURL> mURL;
-
- bool mMutable;
-};
-
-} // namespace net
-} // namespace mozilla
-
-#endif // RustURL_h__
--- a/netwerk/base/moz.build
+++ b/netwerk/base/moz.build
@@ -252,20 +252,16 @@ UNIFIED_SOURCES += [
'SimpleChannel.cpp',
'SimpleChannelParent.cpp',
'TCPFastOpenLayer.cpp',
'ThrottleQueue.cpp',
'Tickler.cpp',
'TLSServerSocket.cpp',
]
-if CONFIG['MOZ_RUST_URLPARSE']:
- EXPORTS.mozilla.net += [ 'RustURL.h' ]
- UNIFIED_SOURCES += [ 'RustURL.cpp' ]
-
if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'windows':
SOURCES += [
'nsURLHelperWin.cpp',
'ShutdownLayer.cpp',
]
elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa':
SOURCES += [
'nsURLHelperOSX.cpp',
--- a/netwerk/base/nsStandardURL.cpp
+++ b/netwerk/base/nsStandardURL.cpp
@@ -22,121 +22,30 @@
#include "nsNetCID.h"
#include "mozilla/MemoryReporting.h"
#include "mozilla/ipc/URIUtils.h"
#include <algorithm>
#include "mozilla/SyncRunnable.h"
#include "nsContentUtils.h"
#include "prprf.h"
#include "nsReadableUtils.h"
+#include "rust-url-capi/src/rust-url-capi.h"
//
// setenv MOZ_LOG nsStandardURL:5
//
static LazyLogModule gStandardURLLog("nsStandardURL");
// The Chromium code defines its own LOG macro which we don't want
#undef LOG
#define LOG(args) MOZ_LOG(gStandardURLLog, LogLevel::Debug, args)
#undef LOG_ENABLED
#define LOG_ENABLED() MOZ_LOG_TEST(gStandardURLLog, LogLevel::Debug)
-#ifdef MOZ_RUST_URLPARSE
-
-#include "RustURL.h"
-
-// Modified on the main thread, read on both main thread and worker threads.
-Atomic<bool> nsStandardURL::gRustEnabled(false);
-
-// Fall back to CPP-parsed URLs if the Rust one doesn't match.
-#define MOZ_RUST_URLPARSE_FALLBACK
-
-#ifdef MOZ_RUST_URLPARSE_FALLBACK
-#define MOZ_RUST_URLPARSE_FALLBACK_MACRO(expr) expr
-#else
-#define MOZ_RUST_URLPARSE_FALLBACK_MACRO(expr)
-#endif
-
-#define CALL_RUST_SETTER(func, ...) \
-do { \
- if (!mRustURL) break; \
- mRustURL->func(__VA_ARGS__); \
- nsAutoCString rustSpec; \
- mRustURL->GetSpec(rustSpec); \
- if (mSpec != rustSpec) { \
- LOG(("Spec diff detected after setter (%s): rust: %s standard-url: %s\n", \
- #func, rustSpec.get(), mSpec.get())); \
- } \
-} while (0)
-
-#define CALL_RUST_GETTER_STR(result, func, ...) \
-do { \
- if (!mRustURL) break; \
- nsAutoCString backup(result); \
- mRustURL->func(__VA_ARGS__); \
- if (backup != result) { \
- LOG(("Diff detected calling getter (%s): rust: %s standard-url: %s\n", \
- #func, result.BeginReading() , backup.BeginReading())); \
- MOZ_RUST_URLPARSE_FALLBACK_MACRO(result = backup); \
- } \
-} while (0)
-
-#define CALL_RUST_GETTER_INT(result, func, ...) \
-do { \
- if (!mRustURL) break; \
- int32_t backup = *result; \
- mRustURL->func(__VA_ARGS__); \
- if (backup != *result) { \
- LOG(("Diff detected calling getter (%s): rust: %d standard-url: %d\n", \
- #func, *result , backup)); \
- MOZ_RUST_URLPARSE_FALLBACK_MACRO(*result = backup); \
- } \
-} while (0)
-
-#define COPY_RUST_MEMBER \
-do { \
- if (!gRustEnabled) break; \
- RefPtr<RustURL> url = new RustURL(); \
- nsAutoCString spec; \
- GetSpec(spec); \
- url->SetSpec(spec); \
- mRustURL = url; \
-} while (0)
-
-#define CALL_RUST_SYNC \
-do { \
- if (!mRustURL) break; \
- mRustURL->SetSpec(mSpec); \
-} while (0)
-
-#define CALL_SET_MUTABLE \
-do { \
- if (!mRustURL) break; \
- mRustURL->SetMutable(value); \
-} while (0)
-
-#define CALL_RUST_INIT \
-do { \
- if (!mRustURL) break; \
- mRustURL->Init(urlType, defaultPort, spec, charset, baseURI); \
-} while (0)
-
-#else
-
-#define CALL_RUST_SETTER(func, ...)
-#define CALL_RUST_GETTER_STR(expected, func, ...)
-#define CALL_RUST_GETTER_INT(expected, func, ...)
-#define CALL_RUST_INIT
-#define CALL_RUST_SYNC
-#define CALL_SET_MUTABLE
-#define COPY_RUST_MEMBER
-
-#endif // MOZ_RUST_URLPARSE
-
using namespace mozilla::ipc;
namespace mozilla {
namespace net {
static NS_DEFINE_CID(kThisImplCID, NS_THIS_STANDARDURL_IMPL_CID);
static NS_DEFINE_CID(kStandardURLCID, NS_STANDARDURL_CID);
@@ -180,18 +89,16 @@ constexpr ASCIIMaskArray sInvalidHostCha
return NS_ERROR_ABORT; \
} \
PR_END_MACRO
//----------------------------------------------------------------------------
// nsStandardURL::nsPrefObserver
//----------------------------------------------------------------------------
-#define NS_NET_PREF_ENABLE_RUST "network.standard-url.enable-rust"
-
NS_IMPL_ISUPPORTS(nsStandardURL::nsPrefObserver, nsIObserver)
NS_IMETHODIMP nsStandardURL::
nsPrefObserver::Observe(nsISupports *subject,
const char *topic,
const char16_t *data)
{
MOZ_ASSERT(NS_IsMainThread());
@@ -317,21 +224,16 @@ nsStandardURL::nsStandardURL(bool aSuppo
#ifdef DEBUG_DUMP_URLS_AT_SHUTDOWN
if (NS_IsMainThread()) {
if (aTrackURL) {
gAllURLs.insertBack(this);
}
}
#endif
-#ifdef MOZ_RUST_URLPARSE
- if (gRustEnabled) {
- mRustURL = new RustURL();
- }
-#endif
}
nsStandardURL::~nsStandardURL()
{
LOG(("Destroying nsStandardURL @%p\n", this));
}
#ifdef DEBUG_DUMP_URLS_AT_SHUTDOWN
@@ -369,19 +271,16 @@ nsStandardURL::InitGlobalObjects()
}
MOZ_ASSERT(NS_IsMainThread());
gInitialized = true;
nsCOMPtr<nsIPrefBranch> prefBranch( do_GetService(NS_PREFSERVICE_CONTRACTID) );
if (prefBranch) {
nsCOMPtr<nsIObserver> obs( new nsPrefObserver() );
-#ifdef MOZ_RUST_URLPARSE
- prefBranch->AddObserver(NS_NET_PREF_ENABLE_RUST, obs.get(), false);
-#endif
PrefsChanged(prefBranch, nullptr);
}
Preferences::AddBoolVarCache(&gPunycodeHost, "network.standard-url.punycode-host", true);
nsCOMPtr<nsIIDNService> serv(do_GetService(NS_IDNSERVICE_CONTRACTID));
if (serv) {
NS_ADDREF(gIDN = serv.get());
MOZ_ASSERT(gIDN);
@@ -1278,26 +1177,16 @@ nsStandardURL::PrefsChanged(nsIPrefBranc
{
MOZ_ASSERT(NS_IsMainThread());
LOG(("nsStandardURL::PrefsChanged [pref=%s]\n", pref));
#define PREF_CHANGED(p) ((pref == nullptr) || !strcmp(pref, p))
#define GOT_PREF(p, b) (NS_SUCCEEDED(prefs->GetBoolPref(p, &b)))
-#ifdef MOZ_RUST_URLPARSE
- bool val;
- if (PREF_CHANGED(NS_NET_PREF_ENABLE_RUST)) {
- if (GOT_PREF(NS_NET_PREF_ENABLE_RUST, val)) {
- gRustEnabled = val;
- }
- LOG(("Rust parser %s\n", gRustEnabled ? "enabled" : "disabled"));
- }
-#endif // MOZ_RUST_URLPARSE
-
#undef PREF_CHANGED
#undef GOT_PREF
}
#define SHIFT_FROM(name, what) \
void \
nsStandardURL::name(int32_t diff) \
{ \
@@ -1366,32 +1255,30 @@ nsStandardURL::GetSpec(nsACString &resul
MOZ_ASSERT(mSpec.Length() <= (uint32_t) net_GetURLMaxLength(),
"The spec should never be this long, we missed a check.");
nsresult rv = NS_OK;
if (gPunycodeHost) {
result = mSpec;
} else { // XXX: This code path may be slow
rv = GetDisplaySpec(result);
}
- CALL_RUST_GETTER_STR(result, GetSpec, result);
return rv;
}
// result may contain unescaped UTF-8 characters
NS_IMETHODIMP
nsStandardURL::GetSensitiveInfoHiddenSpec(nsACString &result)
{
nsresult rv = GetSpec(result);
if (NS_FAILED(rv)) {
return rv;
}
if (mPassword.mLen >= 0) {
result.ReplaceLiteral(mPassword.mPos, mPassword.mLen, "****");
}
- CALL_RUST_GETTER_STR(result, GetSensitiveInfoHiddenSpec, result);
return NS_OK;
}
// result may contain unescaped UTF-8 characters
NS_IMETHODIMP
nsStandardURL::GetSpecIgnoringRef(nsACString &result)
{
// URI without ref is 0 to one char before ref
@@ -1403,17 +1290,16 @@ nsStandardURL::GetSpecIgnoringRef(nsACSt
result = Segment(noRef);
CheckIfHostIsAscii();
MOZ_ASSERT(mCheckedIfHostA);
if (!gPunycodeHost && !mDisplayHost.IsEmpty()) {
result.Replace(mHost.mPos, mHost.mLen, mDisplayHost);
}
- CALL_RUST_GETTER_STR(result, GetSpecIgnoringRef, result);
return NS_OK;
}
nsresult
nsStandardURL::CheckIfHostIsAscii()
{
nsresult rv;
if (mCheckedIfHostA) {
@@ -1499,17 +1385,16 @@ NS_IMETHODIMP
nsStandardURL::GetPrePath(nsACString &result)
{
result = Prepath();
CheckIfHostIsAscii();
MOZ_ASSERT(mCheckedIfHostA);
if (!gPunycodeHost && !mDisplayHost.IsEmpty()) {
result.Replace(mHost.mPos, mHost.mLen, mDisplayHost);
}
- CALL_RUST_GETTER_STR(result, GetPrePath, result);
return NS_OK;
}
// result may contain unescaped UTF-8 characters
NS_IMETHODIMP
nsStandardURL::GetDisplayPrePath(nsACString &result)
{
result = Prepath();
@@ -1521,106 +1406,97 @@ nsStandardURL::GetDisplayPrePath(nsACStr
return NS_OK;
}
// result is strictly US-ASCII
NS_IMETHODIMP
nsStandardURL::GetScheme(nsACString &result)
{
result = Scheme();
- CALL_RUST_GETTER_STR(result, GetScheme, result);
return NS_OK;
}
// result may contain unescaped UTF-8 characters
NS_IMETHODIMP
nsStandardURL::GetUserPass(nsACString &result)
{
result = Userpass();
- CALL_RUST_GETTER_STR(result, GetUserPass, result);
return NS_OK;
}
// result may contain unescaped UTF-8 characters
NS_IMETHODIMP
nsStandardURL::GetUsername(nsACString &result)
{
result = Username();
- CALL_RUST_GETTER_STR(result, GetUsername, result);
return NS_OK;
}
// result may contain unescaped UTF-8 characters
NS_IMETHODIMP
nsStandardURL::GetPassword(nsACString &result)
{
result = Password();
- CALL_RUST_GETTER_STR(result, GetPassword, result);
return NS_OK;
}
NS_IMETHODIMP
nsStandardURL::GetHostPort(nsACString &result)
{
nsresult rv;
if (gPunycodeHost) {
rv = GetAsciiHostPort(result);
} else {
rv = GetDisplayHostPort(result);
}
- CALL_RUST_GETTER_STR(result, GetHostPort, result);
return rv;
}
NS_IMETHODIMP
nsStandardURL::GetHost(nsACString &result)
{
nsresult rv;
if (gPunycodeHost) {
rv = GetAsciiHost(result);
} else {
rv = GetDisplayHost(result);
}
- CALL_RUST_GETTER_STR(result, GetHost, result);
return rv;
}
NS_IMETHODIMP
nsStandardURL::GetPort(int32_t *result)
{
// should never be more than 16 bit
MOZ_ASSERT(mPort <= std::numeric_limits<uint16_t>::max());
*result = mPort;
- CALL_RUST_GETTER_INT(result, GetPort, result);
return NS_OK;
}
// result may contain unescaped UTF-8 characters
NS_IMETHODIMP
nsStandardURL::GetPathQueryRef(nsACString &result)
{
result = Path();
- CALL_RUST_GETTER_STR(result, GetPathQueryRef, result);
return NS_OK;
}
// result is ASCII
NS_IMETHODIMP
nsStandardURL::GetAsciiSpec(nsACString &result)
{
if (mSpecEncoding == eEncoding_Unknown) {
if (IsASCII(mSpec))
mSpecEncoding = eEncoding_ASCII;
else
mSpecEncoding = eEncoding_UTF8;
}
if (mSpecEncoding == eEncoding_ASCII) {
result = mSpec;
- CALL_RUST_GETTER_STR(result, GetAsciiSpec, result);
return NS_OK;
}
// try to guess the capacity required for result...
result.SetCapacity(mSpec.Length() + std::min<uint32_t>(32, mSpec.Length()/10));
result = Substring(mSpec, 0, mScheme.mLen + 3);
@@ -1631,35 +1507,32 @@ nsStandardURL::GetAsciiSpec(nsACString &
// get the hostport
nsAutoCString hostport;
MOZ_ALWAYS_SUCCEEDS(GetAsciiHostPort(hostport));
result += hostport;
// This is left infallible as this entire function is expected to be
// infallible.
NS_EscapeURL(Path(), esc_OnlyNonASCII | esc_AlwaysCopy, result);
- CALL_RUST_GETTER_STR(result, GetAsciiSpec, result);
return NS_OK;
}
// result is ASCII
NS_IMETHODIMP
nsStandardURL::GetAsciiHostPort(nsACString &result)
{
result = Hostport();
- CALL_RUST_GETTER_STR(result, GetAsciiHostPort, result);
return NS_OK;
}
// result is ASCII
NS_IMETHODIMP
nsStandardURL::GetAsciiHost(nsACString &result)
{
result = Host();
- CALL_RUST_GETTER_STR(result, GetAsciiHost, result);
return NS_OK;
}
static bool
IsSpecialProtocol(const nsACString &input)
{
nsACString::const_iterator start, end;
input.BeginReading(start);
@@ -1767,17 +1640,16 @@ nsStandardURL::SetSpecWithEncoding(const
LOG((" filepath = (%u,%d)\n", mFilepath.mPos, mFilepath.mLen));
LOG((" directory = (%u,%d)\n", mDirectory.mPos, mDirectory.mLen));
LOG((" basename = (%u,%d)\n", mBasename.mPos, mBasename.mLen));
LOG((" extension = (%u,%d)\n", mExtension.mPos, mExtension.mLen));
LOG((" query = (%u,%d)\n", mQuery.mPos, mQuery.mLen));
LOG((" ref = (%u,%d)\n", mRef.mPos, mRef.mLen));
}
- CALL_RUST_SETTER(SetSpec, input);
return rv;
}
NS_IMETHODIMP
nsStandardURL::SetScheme(const nsACString &input)
{
ENSURE_MUTABLE();
@@ -1812,17 +1684,16 @@ nsStandardURL::SetScheme(const nsACStrin
ShiftFromAuthority(shift);
}
// ensure new scheme is lowercase
//
// XXX the string code unfortunately doesn't provide a ToLowerCase
// that operates on a substring.
net_ToLowerCase((char *) mSpec.get(), mScheme.mLen);
- CALL_RUST_SETTER(SetScheme, input);
return NS_OK;
}
NS_IMETHODIMP
nsStandardURL::SetUserPass(const nsACString &input)
{
ENSURE_MUTABLE();
@@ -1855,17 +1726,16 @@ nsStandardURL::SetUserPass(const nsACStr
mUsername.mLen++;
mSpec.Cut(mUsername.mPos, mUsername.mLen);
mAuthority.mLen -= mUsername.mLen;
ShiftFromHost(-mUsername.mLen);
mUsername.mLen = -1;
mPassword.mLen = -1;
}
- CALL_RUST_SETTER(SetUserPass, input);
return NS_OK;
}
NS_ASSERTION(mHost.mLen >= 0, "uninitialized");
nsresult rv;
uint32_t usernamePos, passwordPos;
int32_t usernameLen, passwordLen;
@@ -1924,17 +1794,16 @@ nsStandardURL::SetUserPass(const nsACStr
}
// update positions and lengths
mUsername.mLen = usernameLen;
mPassword.mLen = passwordLen;
if (passwordLen > 0) {
mPassword.mPos = mUsername.mPos + mUsername.mLen + 1;
}
- CALL_RUST_SETTER(SetUserPass, input);
return NS_OK;
}
NS_IMETHODIMP
nsStandardURL::SetUsername(const nsACString &input)
{
ENSURE_MUTABLE();
@@ -1975,17 +1844,16 @@ nsStandardURL::SetUsername(const nsACStr
shift = ReplaceSegment(mUsername.mPos, mUsername.mLen, escUsername);
if (shift) {
mUsername.mLen = escUsername.Length();
mAuthority.mLen += shift;
ShiftFromPassword(shift);
}
- CALL_RUST_SETTER(SetUsername, input);
return NS_OK;
}
NS_IMETHODIMP
nsStandardURL::SetPassword(const nsACString &input)
{
ENSURE_MUTABLE();
@@ -2013,17 +1881,16 @@ nsStandardURL::SetPassword(const nsACStr
if (password.IsEmpty()) {
if (mPassword.mLen >= 0) {
// cut(":password")
mSpec.Cut(mPassword.mPos - 1, mPassword.mLen + 1);
ShiftFromHost(-(mPassword.mLen + 1));
mAuthority.mLen -= (mPassword.mLen + 1);
mPassword.mLen = -1;
}
- CALL_RUST_SETTER(SetPassword, input);
return NS_OK;
}
// escape password if necessary
nsAutoCString buf;
nsSegmentEncoder encoder;
const nsACString &escPassword =
encoder.EncodeSegment(password, esc_Password, buf);
@@ -2038,17 +1905,16 @@ nsStandardURL::SetPassword(const nsACStr
else
shift = ReplaceSegment(mPassword.mPos, mPassword.mLen, escPassword);
if (shift) {
mPassword.mLen = escPassword.Length();
mAuthority.mLen += shift;
ShiftFromHost(shift);
}
- CALL_RUST_SETTER(SetPassword, input);
return NS_OK;
}
void
nsStandardURL::FindHostLimit(nsACString::const_iterator& aStart,
nsACString::const_iterator& aEnd)
{
for (int32_t i = 0; gHostLimitDigits[i]; ++i) {
@@ -2122,30 +1988,28 @@ nsStandardURL::SetHostPort(const nsACStr
// Failure parsing port number
return NS_ERROR_MALFORMED_URI;
}
} else {
// port number is missing
return NS_ERROR_MALFORMED_URI;
}
}
- CALL_RUST_SETTER(SetHostPort, aValue);
return NS_OK;
}
// This function is different than SetHostPort in that the port number will be
// reset as well if aValue parameter does not contain a port port number.
NS_IMETHODIMP
nsStandardURL::SetHostAndPort(const nsACString &aValue)
{
// Reset the port and than call SetHostPort. SetHostPort does not reset
// the port number.
nsresult rv = SetPort(-1);
NS_ENSURE_SUCCESS(rv, rv);
- CALL_RUST_SETTER(SetHostAndPort, aValue);
return SetHostPort(aValue);
}
NS_IMETHODIMP
nsStandardURL::SetHost(const nsACString &input)
{
ENSURE_MUTABLE();
@@ -2245,17 +2109,16 @@ nsStandardURL::SetHost(const nsACString
if (shift) {
mHost.mLen = len;
mAuthority.mLen += shift;
ShiftFromPath(shift);
}
// Now canonicalize the host to lowercase
net_ToLowerCase(mSpec.BeginWriting() + mHost.mPos, mHost.mLen);
- CALL_RUST_SETTER(SetHost, input);
return NS_OK;
}
NS_IMETHODIMP
nsStandardURL::SetPort(int32_t port)
{
ENSURE_MUTABLE();
@@ -2277,17 +2140,16 @@ nsStandardURL::SetPort(int32_t port)
InvalidateCache();
if (port == mDefaultPort) {
port = -1;
}
ReplacePortInSpec(port);
mPort = port;
- CALL_RUST_SETTER(SetPort, port);
return NS_OK;
}
/**
* Replaces the existing port in mSpec with aNewPort.
*
* The caller is responsible for:
* - Calling InvalidateCache (since our mSpec is changing).
@@ -2356,17 +2218,16 @@ nsStandardURL::SetPathQueryRef(const nsA
mDirectory.mLen = 1;
mFilepath.mLen = 1;
// these are no longer defined
mBasename.mLen = -1;
mExtension.mLen = -1;
mQuery.mLen = -1;
mRef.mLen = -1;
}
- CALL_RUST_SETTER(SetPathQueryRef, input);
return NS_OK;
}
NS_IMETHODIMP
nsStandardURL::Equals(nsIURI *unknownOther, bool *result)
{
return EqualsInternal(unknownOther, eHonorRef, result);
}
@@ -2540,17 +2401,16 @@ nsresult nsStandardURL::CopyMembers(nsSt
mExtension = source->mExtension;
mQuery = source->mQuery;
mRef = source->mRef;
mURLType = source->mURLType;
mParser = source->mParser;
mMutable = true;
mSupportsFileURL = source->mSupportsFileURL;
- COPY_RUST_MEMBER;
if (copyCached) {
mFile = source->mFile;
mCheckedIfHostA = source->mCheckedIfHostA;
mDisplayHost = source->mDisplayHost;
mSpecEncoding = source->mSpecEncoding;
} else {
InvalidateCache(true);
}
@@ -3080,17 +2940,16 @@ nsStandardURL::SetQueryWithEncoding(cons
if (mQuery.mLen >= 0) {
// remove query and leading '?'
mSpec.Cut(mQuery.mPos - 1, mQuery.mLen + 1);
ShiftFromRef(-(mQuery.mLen + 1));
mPath.mLen -= (mQuery.mLen + 1);
mQuery.mPos = 0;
mQuery.mLen = -1;
}
- CALL_RUST_SETTER(SetQuery, input);
return NS_OK;
}
int32_t queryLen = flat.Length();
if (query[0] == '?') {
query++;
queryLen--;
}
@@ -3121,17 +2980,16 @@ nsStandardURL::SetQueryWithEncoding(cons
int32_t shift = ReplaceSegment(mQuery.mPos, mQuery.mLen, query, queryLen);
if (shift) {
mQuery.mLen = queryLen;
mPath.mLen += shift;
ShiftFromRef(shift);
}
- CALL_RUST_SETTER(SetQuery, input);
return NS_OK;
}
NS_IMETHODIMP
nsStandardURL::SetRef(const nsACString &input)
{
ENSURE_MUTABLE();
@@ -3153,17 +3011,16 @@ nsStandardURL::SetRef(const nsACString &
// remove existing ref
if (mRef.mLen >= 0) {
// remove ref and leading '#'
mSpec.Cut(mRef.mPos - 1, mRef.mLen + 1);
mPath.mLen -= (mRef.mLen + 1);
mRef.mPos = 0;
mRef.mLen = -1;
}
- CALL_RUST_SETTER(SetRef, input);
return NS_OK;
}
int32_t refLen = flat.Length();
if (ref[0] == '#') {
ref++;
refLen--;
}
@@ -3186,17 +3043,16 @@ nsStandardURL::SetRef(const nsACString &
if (encoded) {
ref = buf.get();
refLen = buf.Length();
}
int32_t shift = ReplaceSegment(mRef.mPos, mRef.mLen, ref, refLen);
mPath.mLen += shift;
mRef.mLen = refLen;
- CALL_RUST_SETTER(SetRef, input);
return NS_OK;
}
NS_IMETHODIMP
nsStandardURL::SetDirectory(const nsACString &input)
{
NS_NOTYETIMPLEMENTED("");
return NS_ERROR_NOT_IMPLEMENTED;
@@ -3467,18 +3323,16 @@ nsStandardURL::Init(uint32_t urlType,
if (IsUTFEncoding(encoding)) {
encoding = nullptr;
}
if (baseURI && net_IsAbsoluteURL(spec)) {
baseURI = nullptr;
}
- CALL_RUST_INIT;
-
if (!baseURI)
return SetSpecWithEncoding(spec, encoding);
nsAutoCString buf;
nsresult rv = baseURI->Resolve(spec, buf);
if (NS_FAILED(rv)) return rv;
return SetSpecWithEncoding(buf, encoding);
@@ -3516,17 +3370,16 @@ nsStandardURL::GetMutable(bool *value)
}
NS_IMETHODIMP
nsStandardURL::SetMutable(bool value)
{
NS_ENSURE_ARG(mMutable || !value);
mMutable = value;
- CALL_SET_MUTABLE;
return NS_OK;
}
//----------------------------------------------------------------------------
// nsStandardURL::nsISerializable
//----------------------------------------------------------------------------
NS_IMETHODIMP
@@ -3628,17 +3481,16 @@ nsStandardURL::Read(nsIObjectInputStream
// query and ref already. Bump the mFilePath and
// directory/basename/extension components to include this.
mFilepath.Merge(mSpec, ';', old_param);
mDirectory.Merge(mSpec, ';', old_param);
mBasename.Merge(mSpec, ';', old_param);
mExtension.Merge(mSpec, ';', old_param);
}
- CALL_RUST_SYNC;
return NS_OK;
}
NS_IMETHODIMP
nsStandardURL::Write(nsIObjectOutputStream *stream)
{
MOZ_ASSERT(mSpec.Length() <= (uint32_t) net_GetURLMaxLength(),
"The spec should never be this long, we missed a check.");
@@ -3807,18 +3659,16 @@ nsStandardURL::Deserialize(const URIPara
mDirectory = FromIPCSegment(params.directory());
mBasename = FromIPCSegment(params.baseName());
mExtension = FromIPCSegment(params.extension());
mQuery = FromIPCSegment(params.query());
mRef = FromIPCSegment(params.ref());
mMutable = params.isMutable();
mSupportsFileURL = params.supportsFileURL();
- CALL_RUST_SYNC;
-
// mSpecEncoding and mDisplayHost are just caches that can be recovered as needed.
return true;
}
//----------------------------------------------------------------------------
// nsStandardURL::nsIClassInfo
//----------------------------------------------------------------------------
@@ -3893,14 +3743,14 @@ nsStandardURL::SizeOfExcludingThis(Mallo
size_t
nsStandardURL::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const {
return aMallocSizeOf(this) + SizeOfExcludingThis(aMallocSizeOf);
}
} // namespace net
} // namespace mozilla
-// For unit tests. Including nsStandardURL.h seems to cause problems via RustURL.h
+// For unit tests. Including nsStandardURL.h seems to cause problems
nsresult
Test_NormalizeIPv4(const nsACString& host, nsCString& result)
{
return nsStandardURL::NormalizeIPv4(host, result);
}
--- a/netwerk/base/nsStandardURL.h
+++ b/netwerk/base/nsStandardURL.h
@@ -16,17 +16,16 @@
#include "nsURLHelper.h"
#include "nsIClassInfo.h"
#include "nsISizeOf.h"
#include "mozilla/Attributes.h"
#include "mozilla/LinkedList.h"
#include "mozilla/MemoryReporting.h"
#include "nsIIPCSerializableURI.h"
#include "nsISensitiveInfoHiddenURI.h"
-#include "RustURL.h"
#ifdef NS_BUILD_REFCNT_LOGGING
#define DEBUG_DUMP_URLS_AT_SHUTDOWN
#endif
class nsIBinaryInputStream;
class nsIBinaryOutputStream;
class nsIIDNService;
@@ -306,21 +305,16 @@ private:
static const char gHostLimitDigits[];
static bool gInitialized;
static bool gPunycodeHost;
public:
#ifdef DEBUG_DUMP_URLS_AT_SHUTDOWN
void PrintSpec() const { printf(" %s\n", mSpec.get()); }
#endif
-
-#ifdef MOZ_RUST_URLPARSE
- static Atomic<bool> gRustEnabled;
- RefPtr<RustURL> mRustURL;
-#endif
};
#define NS_THIS_STANDARDURL_IMPL_CID \
{ /* b8e3e97b-1ccd-4b45-af5a-79596770f5d7 */ \
0xb8e3e97b, \
0x1ccd, \
0x4b45, \
{0xaf, 0x5a, 0x79, 0x59, 0x67, 0x70, 0xf5, 0xd7} \
--- a/netwerk/build/nsNetCID.h
+++ b/netwerk/build/nsNetCID.h
@@ -108,28 +108,16 @@
#define NS_STANDARDURL_CID \
{ /* de9472d0-8034-11d3-9399-00104ba0fd40 */ \
0xde9472d0, \
0x8034, \
0x11d3, \
{0x93, 0x99, 0x00, 0x10, 0x4b, 0xa0, 0xfd, 0x40} \
}
-// compoenent implementing nsIStandardURL, nsIURI, nsIURL
-// future replacement for nsStandardURL
-#define NS_RUSTURL_CONTRACTID \
- "@mozilla.org/network/rust-url;1"
-#define NS_RUSTURL_CID \
-{ /* fd2d9f76-b34a-459e-b80e-447b03a1283a */ \
- 0xfd2d9f76, \
- 0xb34a, \
- 0x459e, \
- {0xb8, 0x0e, 0x44, 0x7b, 0x03, 0xa1, 0x28, 0x3a} \
-}
-
// service implementing nsIURLParser that assumes the URL will NOT contain an
// authority section.
#define NS_NOAUTHURLPARSER_CONTRACTID \
"@mozilla.org/network/url-parser;1?auth=no"
#define NS_NOAUTHURLPARSER_CID \
{ /* 78804a84-8173-42b6-bb94-789f0816a810 */ \
0x78804a84, \
0x8173, \
--- a/netwerk/build/nsNetModule.cpp
+++ b/netwerk/build/nsNetModule.cpp
@@ -367,22 +367,16 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsAuthURL
NS_GENERIC_FACTORY_CONSTRUCTOR(nsStdURLParser)
#include "nsStandardURL.h"
typedef mozilla::net::nsStandardURL nsStandardURL;
NS_GENERIC_FACTORY_CONSTRUCTOR(nsStandardURL)
typedef mozilla::net::nsSimpleURI nsSimpleURI;
NS_GENERIC_FACTORY_CONSTRUCTOR(nsSimpleURI)
-#ifdef MOZ_RUST_URLPARSE
-#include "mozilla/net/RustURL.h"
-typedef mozilla::net::RustURL RustURL;
-NS_GENERIC_FACTORY_CONSTRUCTOR(RustURL)
-#endif // MOZ_RUST_URLPARSE
-
typedef mozilla::net::nsSimpleNestedURI nsSimpleNestedURI;
NS_GENERIC_FACTORY_CONSTRUCTOR(nsSimpleNestedURI)
///////////////////////////////////////////////////////////////////////////////
#include "nsIDNService.h"
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsIDNService, Init)
@@ -720,19 +714,16 @@ NS_DEFINE_NAMED_CID(NS_LOCALFILEOUTPUTST
NS_DEFINE_NAMED_CID(NS_ATOMICLOCALFILEOUTPUTSTREAM_CID);
NS_DEFINE_NAMED_CID(NS_SAFELOCALFILEOUTPUTSTREAM_CID);
NS_DEFINE_NAMED_CID(NS_LOCALFILESTREAM_CID);
NS_DEFINE_NAMED_CID(NS_INCREMENTALDOWNLOAD_CID);
NS_DEFINE_NAMED_CID(NS_STDURLPARSER_CID);
NS_DEFINE_NAMED_CID(NS_NOAUTHURLPARSER_CID);
NS_DEFINE_NAMED_CID(NS_AUTHURLPARSER_CID);
NS_DEFINE_NAMED_CID(NS_STANDARDURL_CID);
-#ifdef MOZ_RUST_URLPARSE
-NS_DEFINE_NAMED_CID(NS_RUSTURL_CID);
-#endif
NS_DEFINE_NAMED_CID(NS_ARRAYBUFFERINPUTSTREAM_CID);
NS_DEFINE_NAMED_CID(NS_BUFFEREDINPUTSTREAM_CID);
NS_DEFINE_NAMED_CID(NS_BUFFEREDOUTPUTSTREAM_CID);
NS_DEFINE_NAMED_CID(NS_MIMEINPUTSTREAM_CID);
NS_DEFINE_NAMED_CID(NS_PROTOCOLPROXYSERVICE_CID);
NS_DEFINE_NAMED_CID(NS_STREAMCONVERTERSERVICE_CID);
#if defined(XP_WIN)
NS_DEFINE_NAMED_CID(NS_NAMEDPIPESERVICE_CID);
@@ -846,19 +837,16 @@ static const mozilla::Module::CIDEntry k
{ &kNS_ATOMICLOCALFILEOUTPUTSTREAM_CID, false, nullptr, nsAtomicFileOutputStreamConstructor },
{ &kNS_SAFELOCALFILEOUTPUTSTREAM_CID, false, nullptr, nsSafeFileOutputStreamConstructor },
{ &kNS_LOCALFILESTREAM_CID, false, nullptr, nsFileStreamConstructor },
{ &kNS_INCREMENTALDOWNLOAD_CID, false, nullptr, net_NewIncrementalDownload },
{ &kNS_STDURLPARSER_CID, false, nullptr, nsStdURLParserConstructor },
{ &kNS_NOAUTHURLPARSER_CID, false, nullptr, nsNoAuthURLParserConstructor },
{ &kNS_AUTHURLPARSER_CID, false, nullptr, nsAuthURLParserConstructor },
{ &kNS_STANDARDURL_CID, false, nullptr, nsStandardURLConstructor },
-#ifdef MOZ_RUST_URLPARSE
- { &kNS_RUSTURL_CID, false, nullptr, RustURLConstructor },
-#endif
{ &kNS_ARRAYBUFFERINPUTSTREAM_CID, false, nullptr, ArrayBufferInputStreamConstructor },
{ &kNS_BUFFEREDINPUTSTREAM_CID, false, nullptr, nsBufferedInputStream::Create },
{ &kNS_BUFFEREDOUTPUTSTREAM_CID, false, nullptr, nsBufferedOutputStream::Create },
{ &kNS_MIMEINPUTSTREAM_CID, false, nullptr, nsMIMEInputStreamConstructor },
{ &kNS_PROTOCOLPROXYSERVICE_CID, true, nullptr, nsProtocolProxyServiceConstructor },
{ &kNS_STREAMCONVERTERSERVICE_CID, false, nullptr, CreateNewStreamConvServiceFactory },
#if defined (XP_WIN)
{ &kNS_NAMEDPIPESERVICE_CID, false, NULL, mozilla::net::NamedPipeServiceConstructor },
@@ -974,19 +962,16 @@ static const mozilla::Module::ContractID
{ NS_ATOMICLOCALFILEOUTPUTSTREAM_CONTRACTID, &kNS_ATOMICLOCALFILEOUTPUTSTREAM_CID },
{ NS_SAFELOCALFILEOUTPUTSTREAM_CONTRACTID, &kNS_SAFELOCALFILEOUTPUTSTREAM_CID },
{ NS_LOCALFILESTREAM_CONTRACTID, &kNS_LOCALFILESTREAM_CID },
{ NS_INCREMENTALDOWNLOAD_CONTRACTID, &kNS_INCREMENTALDOWNLOAD_CID },
{ NS_STDURLPARSER_CONTRACTID, &kNS_STDURLPARSER_CID },
{ NS_NOAUTHURLPARSER_CONTRACTID, &kNS_NOAUTHURLPARSER_CID },
{ NS_AUTHURLPARSER_CONTRACTID, &kNS_AUTHURLPARSER_CID },
{ NS_STANDARDURL_CONTRACTID, &kNS_STANDARDURL_CID },
-#ifdef MOZ_RUST_URLPARSE
- { NS_RUSTURL_CONTRACTID, &kNS_RUSTURL_CID },
-#endif
{ NS_ARRAYBUFFERINPUTSTREAM_CONTRACTID, &kNS_ARRAYBUFFERINPUTSTREAM_CID },
{ NS_BUFFEREDINPUTSTREAM_CONTRACTID, &kNS_BUFFEREDINPUTSTREAM_CID },
{ NS_BUFFEREDOUTPUTSTREAM_CONTRACTID, &kNS_BUFFEREDOUTPUTSTREAM_CID },
{ NS_MIMEINPUTSTREAM_CONTRACTID, &kNS_MIMEINPUTSTREAM_CID },
{ NS_PROTOCOLPROXYSERVICE_CONTRACTID, &kNS_PROTOCOLPROXYSERVICE_CID },
{ NS_STREAMCONVERTERSERVICE_CONTRACTID, &kNS_STREAMCONVERTERSERVICE_CID },
#if defined(XP_WIN)
{ NS_NAMEDPIPESERVICE_CONTRACTID, &kNS_NAMEDPIPESERVICE_CID },
deleted file mode 100644
--- a/netwerk/test/unit/test_rusturl.js
+++ /dev/null
@@ -1,475 +0,0 @@
-const nsIStandardURL = Components.interfaces.nsIStandardURL;
-
-let rustIsMissing = false;
-let RustURL;
-try {
- RustURL = Components.Constructor("@mozilla.org/network/rust-url;1",
- "nsIStandardURL",
- "init");
-} catch (e) {
- rustIsMissing = true;
-}
-
-function symmetricEquality(expect, a, b)
-{
- /* Use if/else instead of |do_check_eq(expect, a.spec == b.spec)| so
- that we get the specs output on the console if the check fails.
- */
- if (expect) {
- /* Check all the sub-pieces too, since that can help with
- debugging cases when equals() returns something unexpected */
- /* We don't check port in the loop, because it can be defaulted in
- some cases. */
- ["spec", "prePath", "scheme", "userPass", "username", "password",
- "hostPort", "host", "pathQueryRef", "filePath", "param", "query",
- "ref",
- // TODO: implement these
- //"directory", "fileName", "fileBaseName", "fileExtension"
- ]
- .map(function(prop) {
- dump("Testing '"+ prop + "'\n");
- do_check_eq(a[prop], b[prop]);
- });
- } else {
- do_check_neq(a.spec, b.spec);
- }
- do_check_eq(expect, a.equals(b));
- do_check_eq(expect, b.equals(a));
-}
-
-function stringToURL(str) {
- return (new RustURL(nsIStandardURL.URLTYPE_AUTHORITY, 80,
- str, "UTF-8", null))
- .QueryInterface(Components.interfaces.nsIURL);
-}
-
-function pairToURLs(pair) {
- do_check_eq(pair.length, 2);
- return pair.map(stringToURL);
-}
-
-add_test({ skip_if: () => rustIsMissing }, function test_setEmptyPath()
-{
- var pairs =
- [
- ["http://example.com", "http://example.com/tests/dom/tests"],
- ["http://example.com:80", "http://example.com/tests/dom/tests"],
- ["http://example.com:80/", "http://example.com/tests/dom/test"],
- ["http://example.com/", "http://example.com/tests/dom/tests"],
- ["http://example.com/a", "http://example.com/tests/dom/tests"],
- ["http://example.com:80/a", "http://example.com/tests/dom/tests"],
- ].map(pairToURLs);
-
- for (var [provided, target] of pairs)
- {
- symmetricEquality(false, target, provided);
-
- dump(provided.scheme);
- dump(provided.host);
- dump(provided.port);
- dump(provided.userPass);
- dump(provided.hostPort);
-
- provided.pathQueryRef = "";
- target.pathQueryRef = "";
-
- do_check_eq(provided.spec, target.spec);
- symmetricEquality(true, target, provided);
- }
- run_next_test();
-});
-
-add_test({ skip_if: () => rustIsMissing }, function test_setQuery()
-{
- var pairs =
- [
- ["http://example.com", "http://example.com/?foo"],
- ["http://example.com/bar", "http://example.com/bar?foo"],
- ["http://example.com#bar", "http://example.com/?foo#bar"],
- ["http://example.com/#bar", "http://example.com/?foo#bar"],
- ["http://example.com/?longerthanfoo#bar", "http://example.com/?foo#bar"],
- ["http://example.com/?longerthanfoo", "http://example.com/?foo"],
- /* And one that's nonempty but shorter than "foo" */
- ["http://example.com/?f#bar", "http://example.com/?foo#bar"],
- ["http://example.com/?f", "http://example.com/?foo"],
- ].map(pairToURLs);
-
- for (var [provided, target] of pairs) {
- symmetricEquality(false, provided, target);
-
- provided.query = "foo";
-
- do_check_eq(provided.spec, target.spec);
- symmetricEquality(true, provided, target);
- }
-
- [provided, target] =
- ["http://example.com/#", "http://example.com/?foo#bar"].map(stringToURL);
- symmetricEquality(false, provided, target);
- provided.query = "foo";
- symmetricEquality(false, provided, target);
-
- var newProvided = Components.classes["@mozilla.org/network/io-service;1"]
- .getService(Components.interfaces.nsIIOService)
- .newURI("#bar", null, provided)
- .QueryInterface(Components.interfaces.nsIURL);
-
- do_check_eq(newProvided.spec, target.spec);
- symmetricEquality(true, newProvided, target);
- run_next_test();
-});
-
-add_test({ skip_if: () => rustIsMissing }, function test_setRef()
-{
- var tests =
- [
- ["http://example.com", "", "http://example.com/"],
- ["http://example.com:80", "", "http://example.com:80/"],
- ["http://example.com:80/", "", "http://example.com:80/"],
- ["http://example.com/", "", "http://example.com/"],
- ["http://example.com/a", "", "http://example.com/a"],
- ["http://example.com:80/a", "", "http://example.com:80/a"],
-
- ["http://example.com", "x", "http://example.com/#x"],
- ["http://example.com:80", "x", "http://example.com:80/#x"],
- ["http://example.com:80/", "x", "http://example.com:80/#x"],
- ["http://example.com/", "x", "http://example.com/#x"],
- ["http://example.com/a", "x", "http://example.com/a#x"],
- ["http://example.com:80/a", "x", "http://example.com:80/a#x"],
-
- ["http://example.com", "xx", "http://example.com/#xx"],
- ["http://example.com:80", "xx", "http://example.com:80/#xx"],
- ["http://example.com:80/", "xx", "http://example.com:80/#xx"],
- ["http://example.com/", "xx", "http://example.com/#xx"],
- ["http://example.com/a", "xx", "http://example.com/a#xx"],
- ["http://example.com:80/a", "xx", "http://example.com:80/a#xx"],
-
- ["http://example.com", "xxxxxxxxxxxxxx", "http://example.com/#xxxxxxxxxxxxxx"],
- ["http://example.com:80", "xxxxxxxxxxxxxx", "http://example.com:80/#xxxxxxxxxxxxxx"],
- ["http://example.com:80/", "xxxxxxxxxxxxxx", "http://example.com:80/#xxxxxxxxxxxxxx"],
- ["http://example.com/", "xxxxxxxxxxxxxx", "http://example.com/#xxxxxxxxxxxxxx"],
- ["http://example.com/a", "xxxxxxxxxxxxxx", "http://example.com/a#xxxxxxxxxxxxxx"],
- ["http://example.com:80/a", "xxxxxxxxxxxxxx", "http://example.com:80/a#xxxxxxxxxxxxxx"],
- ];
-
- for (var [before, ref, result] of tests)
- {
- /* Test1: starting with empty ref */
- var a = stringToURL(before);
- a.ref = ref;
- var b = stringToURL(result);
-
- do_check_eq(a.spec, b.spec);
- do_check_eq(ref, b.ref);
- symmetricEquality(true, a, b);
-
- /* Test2: starting with non-empty */
- a.ref = "yyyy";
- var c = stringToURL(before);
- c.ref = "yyyy";
- symmetricEquality(true, a, c);
-
- /* Test3: reset the ref */
- a.ref = "";
- symmetricEquality(true, a, stringToURL(before));
-
- /* Test4: verify again after reset */
- a.ref = ref;
- symmetricEquality(true, a, b);
- }
- run_next_test();
-});
-
-// Bug 960014 - Make nsStandardURL::SetHost less magical around IPv6
-add_test({ skip_if: () => rustIsMissing }, function test_ipv6()
-{
- var url = stringToURL("http://example.com");
- url.host = "[2001::1]";
- do_check_eq(url.host, "2001::1");
-
- url = stringToURL("http://example.com");
- url.hostPort = "[2001::1]:30";
- do_check_eq(url.host, "2001::1");
- do_check_eq(url.port, 30);
- do_check_eq(url.hostPort, "[2001::1]:30");
-
- url = stringToURL("http://example.com");
- url.hostPort = "2001:1";
- do_check_eq(url.host, "0.0.7.209");
- do_check_eq(url.port, 1);
- do_check_eq(url.hostPort, "0.0.7.209:1");
- run_next_test();
-});
-
-add_test({ skip_if: () => rustIsMissing }, function test_ipv6_fail()
-{
- var url = stringToURL("http://example.com");
-
- // TODO: check that the commented behaviours are correct.
- // TODO: add tests checking for the proper result
-
- // Assert.throws(() => { url.host = "2001::1"; }, "missing brackets");
- // Assert.throws(() => { url.host = "[2001::1]:20"; }, "url.host with port");
- Assert.throws(() => { url.host = "[2001::1"; }, "missing last bracket");
- // Assert.throws(() => { url.host = "2001::1]"; }, "missing first bracket");
- Assert.throws(() => { url.host = "2001[::1]"; }, "bad bracket position");
- Assert.throws(() => { url.host = "[]"; }, "empty IPv6 address");
- Assert.throws(() => { url.host = "[hello]"; }, "bad IPv6 address");
- Assert.throws(() => { url.host = "[192.168.1.1]"; }, "bad IPv6 address");
- // Assert.throws(() => { url.hostPort = "2001::1"; }, "missing brackets");
- Assert.throws(() => { url.hostPort = "[2001::1]30"; }, "missing : after IP");
- Assert.throws(() => { url.hostPort = "[2001:1]"; }, "bad IPv6 address");
- Assert.throws(() => { url.hostPort = "[2001:1]10"; }, "bad IPv6 address");
- Assert.throws(() => { url.hostPort = "[2001:1]10:20"; }, "bad IPv6 address");
- Assert.throws(() => { url.hostPort = "[2001:1]:10:20"; }, "bad IPv6 address");
- Assert.throws(() => { url.hostPort = "[2001:1"; }, "bad IPv6 address");
- Assert.throws(() => { url.hostPort = "2001]:1"; }, "bad IPv6 address");
- // Assert.throws(() => { url.hostPort = "2001:1]"; }, "bad IPv6 address");
- Assert.throws(() => { url.hostPort = ""; }, "Empty hostPort should fail");
- // Assert.throws(() => { url.hostPort = "[2001::1]:"; }, "missing port number");
- // Assert.throws(() => { url.hostPort = "[2001::1]:bad"; }, "bad port number");
- run_next_test();
-});
-
-add_test({ skip_if: () => rustIsMissing }, function test_clearedSpec()
-{
- let url = stringToURL("http://example.com:1234");
- url.hostPort = "hostname"
- do_check_eq(url.spec, "http://hostname:1234/");
- url.setHostAndPort("other");
- do_check_eq(url.spec, "http://other/");
- run_next_test();
-});
-
-add_test({ skip_if: () => rustIsMissing }, function test_hostPort()
-{
- var url = stringToURL("http://example.com/path");
- Assert.throws(() => { url.spec = "http: example"; }, "set bad spec");
- Assert.throws(() => { url.spec = ""; }, "set empty spec");
- do_check_eq(url.spec, "http://example.com/path");
- url.host = "allizom.org";
-
- var ref = stringToURL("http://allizom.org/path");
- symmetricEquality(true, url, ref);
- run_next_test();
-});
-
-add_test({ skip_if: () => rustIsMissing }, function test_escapeBrackets()
-{
- // Query
- var url = stringToURL("http://example.com/?a[x]=1");
- do_check_eq(url.spec, "http://example.com/?a[x]=1");
-
- url = stringToURL("http://example.com/?a%5Bx%5D=1");
- do_check_eq(url.spec, "http://example.com/?a%5Bx%5D=1");
-
- url = stringToURL("http://[2001::1]/?a[x]=1");
- do_check_eq(url.spec, "http://[2001::1]/?a[x]=1");
-
- url = stringToURL("http://[2001::1]/?a%5Bx%5D=1");
- do_check_eq(url.spec, "http://[2001::1]/?a%5Bx%5D=1");
-
- // Path
- url = stringToURL("http://example.com/brackets[x]/test");
- do_check_eq(url.spec, "http://example.com/brackets[x]/test");
-
- url = stringToURL("http://example.com/a%5Bx%5D/test");
- do_check_eq(url.spec, "http://example.com/a%5Bx%5D/test");
- run_next_test();
-});
-
-add_test({ skip_if: () => rustIsMissing }, function test_apostropheEncoding()
-{
- // For now, single quote is escaped everywhere _except_ the path.
- // This policy is controlled by the bitmask in nsEscape.cpp::EscapeChars[]
- var url = stringToURL("http://example.com/dir'/file'.ext'");
- do_check_eq(url.spec, "http://example.com/dir'/file'.ext'");
- run_next_test();
-});
-
-add_test({ skip_if: () => rustIsMissing }, function test_accentEncoding()
-{
- var url = stringToURL("http://example.com/?hello=`");
- do_check_eq(url.spec, "http://example.com/?hello=`");
- do_check_eq(url.query, "hello=`");
-
- url = stringToURL("http://example.com/?hello=%2C");
- do_check_eq(url.spec, "http://example.com/?hello=%2C");
- do_check_eq(url.query, "hello=%2C");
- run_next_test();
-});
-
-add_test({ skip_if: () => rustIsMissing }, function test_percentDecoding()
-{
- var url = stringToURL("http://%70%61%73%74%65%62%69%6E.com");
- do_check_eq(url.spec, "http://pastebin.com/");
-
- // We shouldn't unescape characters that are not allowed in the hostname.
-
- // TODO: rust-url's behaviour is correct here. Check that it throws!
- // url = stringToURL("http://example.com%0a%23.google.com/");
- // do_check_eq(url.spec, "http://example.com%0a%23.google.com/");
- run_next_test();
-});
-
-// TODO: rust-url does not enforce a maximum length for the URL at the moment
-add_test({ skip_if: () => true }, function test_hugeStringThrows()
-{
- let prefs = Cc["@mozilla.org/preferences-service;1"]
- .getService(Ci.nsIPrefService);
- let maxLen = prefs.getIntPref("network.standard-url.max-length");
- let url = stringToURL("http://test:test@example.com");
-
- let hugeString = new Array(maxLen + 1).fill("a").join("");
- let properties = ["spec", "scheme", "userPass", "username",
- "password", "hostPort", "host", "pathQueryRef", "ref",
- "query", "fileName", "filePath", "fileBaseName", "fileExtension"];
- for (let prop of properties) {
- Assert.throws(() => url[prop] = hugeString,
- /NS_ERROR_MALFORMED_URI/,
- `Passing a huge string to "${prop}" should throw`);
- }
-
- run_next_test();
-});
-
-add_test({ skip_if: () => rustIsMissing }, function test_filterWhitespace()
-{
- var url = stringToURL(" \r\n\th\nt\rt\tp://ex\r\n\tample.com/path\r\n\t/\r\n\tto the/fil\r\n\te.e\r\n\txt?que\r\n\try#ha\r\n\tsh \r\n\t ");
- do_check_eq(url.spec, "http://example.com/path/to%20the/file.ext?query#hash");
-
- // These setters should escape \r\n\t, not filter them.
- var url = stringToURL("http://test.com/path?query#hash");
- url.filePath = "pa\r\n\tth"; // TODO: strips from path
- // do_check_eq(url.spec, "http://test.com/pa%0D%0A%09th?query#hash");
- url.query = "qu\r\n\tery"; // TODO: strips from query
- // do_check_eq(url.spec, "http://test.com/pa%0D%0A%09th?qu%0D%0A%09ery#hash");
- url.ref = "ha\r\n\tsh"; // TODO: strips from hash
- // do_check_eq(url.spec, "http://test.com/pa%0D%0A%09th?qu%0D%0A%09ery#ha%0D%0A%09sh");
- // url.fileName = "fi\r\n\tle.name"; // TODO: filename not implemented
- // do_check_eq(url.spec, "http://test.com/fi%0D%0A%09le.name?qu%0D%0A%09ery#ha%0D%0A%09sh");
-
- run_next_test();
-});
-
-add_test({ skip_if: () => rustIsMissing }, function test_backslashReplacement()
-{
- var url = stringToURL("http:\\\\test.com\\path/to\\file?query\\backslash#hash\\");
- do_check_eq(url.spec, "http://test.com/path/to/file?query\\backslash#hash\\");
-
- url = stringToURL("http:\\\\test.com\\example.org/path\\to/file");
- do_check_eq(url.spec, "http://test.com/example.org/path/to/file");
- do_check_eq(url.host, "test.com");
- do_check_eq(url.pathQueryRef, "/example.org/path/to/file");
-
- run_next_test();
-});
-
-add_test({ skip_if: () => rustIsMissing }, function test_trim_C0_and_space()
-{
- var url = stringToURL("\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f http://example.com/ \x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f ");
- do_check_eq(url.spec, "http://example.com/");
- url.spec = "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f http://test.com/ \x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f ";
- do_check_eq(url.spec, "http://test.com/");
- Assert.throws(() => { url.spec = "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19 "; }, "set empty spec");
- run_next_test();
-});
-
-// This tests that C0-and-space characters in the path, query and ref are
-// percent encoded.
-add_test({ skip_if: () => rustIsMissing }, function test_encode_C0_and_space()
-{
- function toHex(d) {
- var hex = d.toString(16);
- if (hex.length == 1)
- hex = "0"+hex;
- return hex.toUpperCase();
- }
-
- for (var i=0x0; i<=0x20; i++) {
- // These characters get filtered - they are not encoded.
- if (String.fromCharCode(i) == '\r' ||
- String.fromCharCode(i) == '\n' ||
- String.fromCharCode(i) == '\t') {
- continue;
- }
- var url = stringToURL("http://example.com/pa" + String.fromCharCode(i) + "th?qu" + String.fromCharCode(i) +"ery#ha" + String.fromCharCode(i) + "sh");
- // TODO: "http://example.com/pa%00th?qu%00ery#hash" == "http://example.com/pa%00th?qu%00ery#ha%00sh"
- // TODO: "http://example.com/pa%01th?qu%01ery#ha\\u0001sh" == "http://example.com/pa%01th?qu%01ery#ha%01sh"
- // do_check_eq(url.spec, "http://example.com/pa%" + toHex(i) + "th?qu%" + toHex(i) + "ery#ha%" + toHex(i) + "sh");
- }
-
- // Additionally, we need to check the setters.
- var url = stringToURL("http://example.com/path?query#hash");
- url.filePath = "pa\0th";
- do_check_eq(url.spec, "http://example.com/pa%00th?query#hash");
- url.query = "qu\0ery";
- do_check_eq(url.spec, "http://example.com/pa%00th?qu%00ery#hash");
- url.ref = "ha\0sh"; // TODO: \0 is stripped
- // do_check_eq(url.spec, "http://example.com/pa%00th?qu%00ery#ha%00sh");
- // url.fileName = "fi\0le.name"; // TODO: not implemented
- // do_check_eq(url.spec, "http://example.com/fi%00le.name?qu%00ery#ha%00sh");
-
- run_next_test();
-});
-
-add_test({ skip_if: () => rustIsMissing }, function test_ipv4Normalize()
-{
- var localIPv4s =
- ["http://127.0.0.1",
- "http://127.0.1",
- "http://127.1",
- "http://2130706433",
- "http://0177.00.00.01",
- "http://0177.00.01",
- "http://0177.01",
- "http://00000000000000000000000000177.0000000.0000000.0001",
- "http://000000177.0000001",
- "http://017700000001",
- "http://0x7f.0x00.0x00.0x01",
- "http://0x7f.0x01",
- "http://0x7f000001",
- "http://0x007f.0x0000.0x0000.0x0001",
- "http://000177.0.00000.0x0001",
- "http://127.0.0.1.",
- ].map(stringToURL);
- var url;
- for (url of localIPv4s) {
- do_check_eq(url.spec, "http://127.0.0.1/");
- }
-
- // These should treated as a domain instead of an IPv4.
- var nonIPv4s =
- ["http://0xfffffffff/",
- "http://0x100000000/",
- "http://4294967296/",
- // "http://1.2.0x10000/", // TODO: fails to parse
- // "http://1.0x1000000/", // TODO: fails to parse
- // "http://256.0.0.1/", // TODO: fails to parse
- // "http://1.256.1/", // TODO: fails to parse
- // "http://-1.0.0.0/", // TODO: fails to parse
- "http://1.2.3.4.5/",
- "http://010000000000000000/",
- // "http://2+3/", // TODO: fails to parse
- // "http://0.0.0.-1/", // TODO: fails to parse
- "http://1.2.3.4../",
- "http://1..2/",
- // "http://.1.2.3.4/", // TODO: parsed as "http://1.2.3.4/"
- ];
- var spec;
- for (spec of nonIPv4s) {
- url = stringToURL(spec);
- do_check_eq(url.spec, spec);
- }
-
- run_next_test();
-});
-
-add_test({ skip_if: () => rustIsMissing }, function test_schemeIsCaseInsensitive()
-{
- var url = stringToURL("http://example.com/");
- do_check_true(url.schemeIs("http"));
- do_check_true(url.schemeIs("HtTp"));
-
- run_next_test();
-});
--- a/netwerk/test/unit/xpcshell.ini
+++ b/netwerk/test/unit/xpcshell.ini
@@ -389,17 +389,16 @@ skip-if = os == "android"
[test_alt-data_stream.js]
[test_alt-data_overwrite.js]
[test_cache-control_request.js]
[test_bug1279246.js]
[test_throttlequeue.js]
[test_throttlechannel.js]
[test_throttling.js]
[test_separate_connections.js]
-[test_rusturl.js]
[test_trackingProtection_annotateChannels.js]
[test_race_cache_with_network.js]
[test_channel_priority.js]
[test_bug1312774_http1.js]
[test_1351443-missing-NewChannel2.js]
[test_bug1312782_http1.js]
[test_bug1355539_http1.js]
[test_bug1378385_http1.js]
--- a/old-configure.in
+++ b/old-configure.in
@@ -2210,22 +2210,16 @@ esac
if test -n "$MOZ_GRAPHENE"; then
AC_DEFINE(MOZ_GRAPHENE)
fi
if test -n "$MOZ_MULET"; then
AC_DEFINE(MOZ_MULET)
fi
-# Propagate feature switches for code written in rust from confvars.sh
-if test -n "$MOZ_RUST_URLPARSE"; then
- AC_DEFINE(MOZ_RUST_URLPARSE)
- AC_SUBST(MOZ_RUST_URLPARSE)
-fi
-
AC_SUBST(MOZ_PHOENIX)
AC_SUBST(MOZ_XULRUNNER)
AC_SUBST(MOZ_MULET)
dnl ========================================================
dnl Ensure Android SDK and build-tools versions depending on
dnl mobile target.
dnl ========================================================