This is an automated email from the git hooks/post-receive script.
richard pushed a commit to branch tor-browser-91.13.0esr-11.5-1 in repository tor-browser.
commit c70f1d687f3275d8aed7ae111c6aac8fe6d796b4 Author: Masatoshi Kimura VYV03354@nifty.ne.jp AuthorDate: Tue Sep 6 15:59:06 2022 +0000
Bug 1787633 - Make nsTextToSubURI::UnEscapeNonAsciiURI static. r=m_kato, a=RyanVM
Differential Revision: https://phabricator.services.mozilla.com/D156007 --- dom/jsurl/nsJSProtocolHandler.cpp | 12 +++--------- intl/uconv/moz.build | 1 + intl/uconv/nsITextToSubURI.idl | 1 + intl/uconv/nsTextToSubURI.cpp | 14 +++++++++++--- intl/uconv/nsTextToSubURI.h | 10 ++++++++-- uriloader/exthandler/win/nsMIMEInfoWin.cpp | 11 +++-------- 6 files changed, 27 insertions(+), 22 deletions(-)
diff --git a/dom/jsurl/nsJSProtocolHandler.cpp b/dom/jsurl/nsJSProtocolHandler.cpp index 09b729442ed5..9257bb933924 100644 --- a/dom/jsurl/nsJSProtocolHandler.cpp +++ b/dom/jsurl/nsJSProtocolHandler.cpp @@ -36,10 +36,10 @@ #include "mozilla/dom/Document.h" #include "nsIObjectInputStream.h" #include "nsIObjectOutputStream.h" -#include "nsITextToSubURI.h" #include "nsIWritablePropertyBag2.h" #include "nsIContentSecurityPolicy.h" #include "nsSandboxFlags.h" +#include "nsTextToSubURI.h" #include "mozilla/BasePrincipal.h" #include "mozilla/CycleCollectedJSContext.h" #include "mozilla/dom/AutoEntryScript.h" @@ -1100,15 +1100,9 @@ NS_IMPL_ISUPPORTS(nsJSProtocolHandler, nsIProtocolHandler) const nsCString& aSpec, const char* aCharset, nsACString& aUTF8Spec) { aUTF8Spec.Truncate();
- nsresult rv; - - nsCOMPtr<nsITextToSubURI> txtToSubURI = - do_GetService(NS_ITEXTTOSUBURI_CONTRACTID, &rv); - NS_ENSURE_SUCCESS(rv, rv); - nsAutoString uStr; - rv = txtToSubURI->UnEscapeNonAsciiURI(nsDependentCString(aCharset), aSpec, - uStr); + nsresult rv = nsTextToSubURI::UnEscapeNonAsciiURI( + nsDependentCString(aCharset), aSpec, uStr); NS_ENSURE_SUCCESS(rv, rv);
if (!IsAscii(uStr)) { diff --git a/intl/uconv/moz.build b/intl/uconv/moz.build index acad06dfa178..1e5db20d720a 100644 --- a/intl/uconv/moz.build +++ b/intl/uconv/moz.build @@ -15,6 +15,7 @@ XPIDL_MODULE = "uconv"
EXPORTS += [ "nsConverterInputStream.h", + "nsTextToSubURI.h", ]
UNIFIED_SOURCES += [ diff --git a/intl/uconv/nsITextToSubURI.idl b/intl/uconv/nsITextToSubURI.idl index ce53121a296b..075952648eaf 100644 --- a/intl/uconv/nsITextToSubURI.idl +++ b/intl/uconv/nsITextToSubURI.idl @@ -47,5 +47,6 @@ interface nsITextToSubURI : nsISupports * @throws NS_ERROR_UCONV_NOCONV when there is no decoder for aCharset * or NS_ERROR_UDEC_ILLEGALINPUT in case of conversion failure */ + [binaryname(UnEscapeNonAsciiURIJS)] AString unEscapeNonAsciiURI(in ACString aCharset, in AUTF8String aURIFragment); }; diff --git a/intl/uconv/nsTextToSubURI.cpp b/intl/uconv/nsTextToSubURI.cpp index b293a93ec595..cb52a7dc9a6e 100644 --- a/intl/uconv/nsTextToSubURI.cpp +++ b/intl/uconv/nsTextToSubURI.cpp @@ -73,6 +73,7 @@ static bool statefulCharset(const char* charset) { return false; }
+// static nsresult nsTextToSubURI::convertURItoUnicode(const nsCString& aCharset, const nsCString& aURI, nsAString& aOut) { @@ -138,9 +139,16 @@ NS_IMETHODIMP nsTextToSubURI::UnEscapeURIForUI(const nsACString& aURIFragment, }
NS_IMETHODIMP -nsTextToSubURI::UnEscapeNonAsciiURI(const nsACString& aCharset, - const nsACString& aURIFragment, - nsAString& _retval) { +nsTextToSubURI::UnEscapeNonAsciiURIJS(const nsACString& aCharset, + const nsACString& aURIFragment, + nsAString& _retval) { + return UnEscapeNonAsciiURI(aCharset, aURIFragment, _retval); +} + +// static +nsresult nsTextToSubURI::UnEscapeNonAsciiURI(const nsACString& aCharset, + const nsACString& aURIFragment, + nsAString& _retval) { nsAutoCString unescapedSpec; NS_UnescapeURL(PromiseFlatCString(aURIFragment), esc_AlwaysCopy | esc_OnlyNonASCII, unescapedSpec); diff --git a/intl/uconv/nsTextToSubURI.h b/intl/uconv/nsTextToSubURI.h index 6b2b742888b3..1eaeb554dc89 100644 --- a/intl/uconv/nsTextToSubURI.h +++ b/intl/uconv/nsTextToSubURI.h @@ -15,12 +15,18 @@ class nsTextToSubURI : public nsITextToSubURI { NS_DECL_ISUPPORTS NS_DECL_NSITEXTTOSUBURI
+ // Thread-safe function for C++ callers + static nsresult UnEscapeNonAsciiURI(const nsACString& aCharset, + const nsACString& aURIFragment, + nsAString& _retval); + private: virtual ~nsTextToSubURI();
// We assume that the URI is encoded as UTF-8. - nsresult convertURItoUnicode(const nsCString& aCharset, const nsCString& aURI, - nsAString& _retval); + static nsresult convertURItoUnicode(const nsCString& aCharset, + const nsCString& aURI, + nsAString& _retval);
// Characters defined in netwerk/dns/IDNCharacterBlocklist.inc or via the // network.IDN.extra_allowed_chars and network.IDN.extra_blocked_chars prefs. diff --git a/uriloader/exthandler/win/nsMIMEInfoWin.cpp b/uriloader/exthandler/win/nsMIMEInfoWin.cpp index b7007ff89d78..267076749ae1 100644 --- a/uriloader/exthandler/win/nsMIMEInfoWin.cpp +++ b/uriloader/exthandler/win/nsMIMEInfoWin.cpp @@ -16,7 +16,7 @@ #include <shlobj.h> #include "nsIWindowsRegKey.h" #include "nsUnicharUtils.h" -#include "nsITextToSubURI.h" +#include "nsTextToSubURI.h" #include "nsVariant.h" #include "mozilla/CmdLineAndEnvUtils.h" #include "mozilla/ShellHeaderOnlyUtils.h" @@ -283,13 +283,8 @@ nsresult nsMIMEInfoWin::LoadUriInternal(nsIURI* aURL) {
// Unescape non-ASCII characters in the URL nsAutoString utf16Spec; - - nsCOMPtr<nsITextToSubURI> textToSubURI = - do_GetService(NS_ITEXTTOSUBURI_CONTRACTID, &rv); - NS_ENSURE_SUCCESS(rv, rv); - - if (NS_FAILED(textToSubURI->UnEscapeNonAsciiURI("UTF-8"_ns, urlSpec, - utf16Spec))) { + if (NS_FAILED(nsTextToSubURI::UnEscapeNonAsciiURI("UTF-8"_ns, urlSpec, + utf16Spec))) { CopyASCIItoUTF16(urlSpec, utf16Spec); }