Bug 691690 - Part 1: Add UTF-8 flag to createFixupURI. r=bz
authorMasatoshi Kimura <VYV03354@nifty.ne.jp>
Wed, 26 Oct 2011 14:27:16 +0200
changeset 76379 ff142e5fea3652bef7abc129f0189845a3a8f4f4
parent 76378 b3528a0ab1f7177242a7ab2c547b6a28e3705ccc
child 76380 9e0f94a06cac1ee09805ca5a156e1ad7f2e5a75b
push id311
push userdgottwald@mozilla.com
push dateWed, 26 Oct 2011 12:28:37 +0000
treeherdermozilla-beta@9e0f94a06cac [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz
bugs691690
milestone8.0
Bug 691690 - Part 1: Add UTF-8 flag to createFixupURI. r=bz
docshell/base/nsDefaultURIFixup.cpp
docshell/base/nsIURIFixup.idl
--- a/docshell/base/nsDefaultURIFixup.cpp
+++ b/docshell/base/nsDefaultURIFixup.cpp
@@ -231,16 +231,17 @@ nsDefaultURIFixup::CreateFixupURI(const 
 #endif
     }
 
     // For these protocols, use system charset instead of the default UTF-8,
     // if the URI is non ASCII.
     PRBool bAsciiURI = IsASCII(uriString);
     PRBool bUseNonDefaultCharsetForURI =
                         !bAsciiURI &&
+                        !(aFixupFlags & FIXUP_FLAG_USE_UTF8) &&
                         (scheme.IsEmpty() ||
                          scheme.LowerCaseEqualsLiteral("http") ||
                          scheme.LowerCaseEqualsLiteral("https") ||
                          scheme.LowerCaseEqualsLiteral("ftp") ||
                          scheme.LowerCaseEqualsLiteral("file"));
 
     // Now we need to check whether "scheme" is something we don't
     // really know about.
@@ -317,17 +318,17 @@ nsDefaultURIFixup::CreateFixupURI(const 
 
         // insert url spec corresponding to host name
         if (IsLikelyFTP(hostSpec))
             uriString.Assign(NS_LITERAL_CSTRING("ftp://") + uriString);
         else 
             uriString.Assign(NS_LITERAL_CSTRING("http://") + uriString);
 
         // For ftp & http, we want to use system charset.
-        if (!bAsciiURI)
+        if (!bAsciiURI && !(aFixupFlags & FIXUP_FLAG_USE_UTF8))
           bUseNonDefaultCharsetForURI = PR_TRUE;
     } // end if checkprotocol
 
     rv = NS_NewURI(aURI, uriString, bUseNonDefaultCharsetForURI ? GetCharsetForUrlBar() : nsnull);
 
     // Did the caller want us to try an alternative URI?
     // If so, attempt to fixup http://foo into http://www.foo.com
 
--- a/docshell/base/nsIURIFixup.idl
+++ b/docshell/base/nsIURIFixup.idl
@@ -59,16 +59,21 @@ interface nsIURIFixup : nsISupports
 
     /**
      * Tell the fixup to make an alternate URI from the input URI, for example
      * to turn foo into www.foo.com.
      */
     const unsigned long FIXUP_FLAGS_MAKE_ALTERNATE_URI = 2;
 
     /**
+     * Use UTF-8 to encode the URI instead of platform charset.
+     */
+    const unsigned long FIXUP_FLAG_USE_UTF8 = 4;
+
+    /**
      * Converts an internal URI (e.g. a wyciwyg URI) into one which we can
      * expose to the user, for example on the URL bar.
      *
      * @param  aURI       The URI to be converted
      * @return nsIURI     The converted, exposable URI
      * @throws NS_ERROR_MALFORMED_URI when the exposable portion of aURI is malformed
      * @throws NS_ERROR_UNKNOWN_PROTOCOL when we can't get a protocol handler service
      *         for the URI scheme.