[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [Git][tpo/applications/tor-browser][tor-browser-115.5.0esr-13.0-1] Bug 42288: Allow language spoofing in status messages.



Title: GitLab

ma1 pushed to branch tor-browser-115.5.0esr-13.0-1 at The Tor Project / Applications / Tor Browser

Commits:

  • da97b52c
    by hackademix at 2023-11-29T23:41:14+01:00
    Bug 42288: Allow language spoofing in status messages.
    

8 changed files:

Changes:

  • browser/installer/package-manifest.in
    ... ... @@ -321,6 +321,7 @@
    321 321
     @RESPATH@/res/locale/layout/HtmlForm.properties
    
    322 322
     @RESPATH@/res/locale/layout/MediaDocument.properties
    
    323 323
     @RESPATH@/res/locale/layout/xmlparser.properties
    
    324
    +@RESPATH@/res/locale/xslt/xslt.properties
    
    324 325
     @RESPATH@/res/locale/dom/dom.properties
    
    325 326
     #ifdef XP_MACOSX
    
    326 327
     @RESPATH@/res/MainMenu.nib/
    

  • dom/locales/moz.build
    ... ... @@ -57,6 +57,10 @@ RESOURCE_FILES.locale.layout += [
    57 57
         "en-US/chrome/layout/xmlparser.properties",
    
    58 58
     ]
    
    59 59
     
    
    60
    +RESOURCE_FILES.locale.xslt += [
    
    61
    +    "en-US/chrome/xslt/xslt.properties",
    
    62
    +]
    
    63
    +
    
    60 64
     RESOURCE_FILES.locale.dom += [
    
    61 65
         "en-US/chrome/dom/dom.properties",
    
    62 66
     ]

  • dom/xslt/xslt/txMozillaXSLTProcessor.cpp
    ... ... @@ -942,11 +942,17 @@ void txMozillaXSLTProcessor::reportError(nsresult aResult,
    942 942
             mozilla::components::StringBundle::Service();
    
    943 943
         if (sbs) {
    
    944 944
           nsString errorText;
    
    945
    -      sbs->FormatStatusMessage(aResult, u"", errorText);
    
    945
    +      bool spoofLocale = nsContentUtils::SpoofLocaleEnglish();
    
    946
    +      if (spoofLocale && mSource) {
    
    947
    +        Document* sourceDoc = mSource->OwnerDoc();
    
    948
    +        spoofLocale = !(sourceDoc && sourceDoc->AllowsL10n());
    
    949
    +      }
    
    950
    +      sbs->FormatStatusMessage(aResult, u"", spoofLocale, errorText);
    
    946 951
     
    
    947 952
           nsAutoString errorMessage;
    
    948 953
           nsCOMPtr<nsIStringBundle> bundle;
    
    949
    -      sbs->CreateBundle(XSLT_MSGS_URL, getter_AddRefs(bundle));
    
    954
    +      sbs->CreateBundle(spoofLocale ? XSLT_MSGS_URL_en_US : XSLT_MSGS_URL,
    
    955
    +        getter_AddRefs(bundle));
    
    950 956
     
    
    951 957
           if (bundle) {
    
    952 958
             AutoTArray<nsString, 1> error = {errorText};
    

  • dom/xslt/xslt/txXSLTMsgsURL.h
    ... ... @@ -7,5 +7,6 @@
    7 7
     #define DOM_XSLT_XSLT_TXXSLTMSGSURL_H_
    
    8 8
     
    
    9 9
     #define XSLT_MSGS_URL "chrome://global/locale/xslt/xslt.properties"
    
    10
    +#define XSLT_MSGS_URL_en_US "resource://gre/res/locale/xslt/xslt.properties"
    
    10 11
     
    
    11 12
     #endif  // DOM_XSLT_XSLT_TXXSLTMSGSURL_H_

  • intl/strres/nsIStringBundle.idl
    ... ... @@ -86,9 +86,13 @@ interface nsIStringBundleService : nsISupports
    86 86
        *            used in the string lookup process.
    
    87 87
        * @param aStatusArg - The status message argument(s). Multiple arguments
    
    88 88
        *            can be separated by newline ('\n') characters.
    
    89
    +   * @param aSpoofLocale - If true (default is false), forces the en-US
    
    90
    +                locale on content-accessible messages (XSLT errors so far).
    
    89 91
        * @return the formatted message
    
    90 92
        */
    
    91
    -  AString formatStatusMessage(in nsresult aStatus, in wstring aStatusArg);
    
    93
    +  AString formatStatusMessage(in nsresult aStatus,
    
    94
    +                              in wstring aStatusArg,
    
    95
    +                              [optional] in boolean aSpoofLocale);
    
    92 96
     
    
    93 97
       /**
    
    94 98
        * flushes the string bundle cache - useful when the locale changes or
    

  • intl/strres/nsStringBundle.cpp
    ... ... @@ -977,6 +977,7 @@ nsresult nsStringBundleService::FormatWithBundle(
    977 977
     NS_IMETHODIMP
    
    978 978
     nsStringBundleService::FormatStatusMessage(nsresult aStatus,
    
    979 979
                                                const char16_t* aStatusArg,
    
    980
    +                                           bool aSpoofLocale,
    
    980 981
                                                nsAString& result) {
    
    981 982
       uint32_t i, argCount = 0;
    
    982 983
       nsCOMPtr<nsIStringBundle> bundle;
    
    ... ... @@ -1012,7 +1013,8 @@ nsStringBundleService::FormatStatusMessage(nsresult aStatus,
    1012 1013
     
    
    1013 1014
       switch (NS_ERROR_GET_MODULE(aStatus)) {
    
    1014 1015
         case NS_ERROR_MODULE_XSLT:
    
    1015
    -      getStringBundle(XSLT_MSGS_URL, getter_AddRefs(bundle));
    
    1016
    +      getStringBundle(aSpoofLocale ? XSLT_MSGS_URL_en_US : XSLT_MSGS_URL,
    
    1017
    +        getter_AddRefs(bundle));
    
    1016 1018
           break;
    
    1017 1019
         case NS_ERROR_MODULE_NETWORK:
    
    1018 1020
           getStringBundle(NECKO_MSGS_URL, getter_AddRefs(bundle));
    

  • mobile/android/installer/package-manifest.in
    ... ... @@ -185,6 +185,7 @@
    185 185
     @BINPATH@/res/locale/layout/HtmlForm.properties
    
    186 186
     @BINPATH@/res/locale/layout/MediaDocument.properties
    
    187 187
     @BINPATH@/res/locale/layout/xmlparser.properties
    
    188
    +@BINPATH@/res/locale/xslt/xslt.properties
    
    188 189
     @BINPATH@/res/locale/dom/dom.properties
    
    189 190
     
    
    190 191
     #ifndef MOZ_ANDROID_EXCLUDE_FONTS
    

  • uriloader/base/nsDocLoader.cpp
    ... ... @@ -1230,7 +1230,7 @@ NS_IMETHODIMP nsDocLoader::OnStatus(nsIRequest* aRequest, nsresult aStatus,
    1230 1230
             mozilla::components::StringBundle::Service();
    
    1231 1231
         if (!sbs) return NS_ERROR_FAILURE;
    
    1232 1232
         nsAutoString msg;
    
    1233
    -    nsresult rv = sbs->FormatStatusMessage(aStatus, aStatusArg, msg);
    
    1233
    +    nsresult rv = sbs->FormatStatusMessage(aStatus, aStatusArg, false, msg);
    
    1234 1234
         if (NS_FAILED(rv)) return rv;
    
    1235 1235
     
    
    1236 1236
         // Keep around the message. In case a request finishes, we need to make sure
    

  • _______________________________________________
    tor-commits mailing list
    tor-commits@xxxxxxxxxxxxxxxxxxxx
    https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits