Bug 1275746 - nsNavHistory::AsciiHostNameFromHostString return empty string if host is empty r=mak
authorValentin Gosu <valentin.gosu@gmail.com>
Wed, 13 Jul 2016 15:19:37 +0300
changeset 387167 b31c2afa920a8f74ddddf0dc8d3eed7fef4ce795
parent 387166 759531230ceca953b4a737cd9e2cb43a3f7c9607
child 387168 0ad1ec384324f0c7c2df6e3b76347f481d6e213e
push id22898
push userCallek@gmail.com
push dateWed, 13 Jul 2016 13:20:13 +0000
reviewersmak
bugs1275746
milestone50.0a1
Bug 1275746 - nsNavHistory::AsciiHostNameFromHostString return empty string if host is empty r=mak MozReview-Commit-ID: 3AKgNCXPKoU
toolkit/components/places/nsNavHistory.cpp
--- a/toolkit/components/places/nsNavHistory.cpp
+++ b/toolkit/components/places/nsNavHistory.cpp
@@ -944,16 +944,20 @@ nsNavHistory::EvaluateQueryForNode(const
 //    We might have interesting encodings and different case in the host name.
 //    This will convert that host name into an ASCII host name by sending it
 //    through the URI canonicalization. The result can be used for comparison
 //    with other ASCII host name strings.
 nsresult // static
 nsNavHistory::AsciiHostNameFromHostString(const nsACString& aHostName,
                                           nsACString& aAscii)
 {
+  aAscii.Truncate();
+  if (aHostName.IsEmpty()) {
+    return NS_OK;
+  }
   // To properly generate a uri we must provide a protocol.
   nsAutoCString fakeURL("http://");
   fakeURL.Append(aHostName);
   nsCOMPtr<nsIURI> uri;
   nsresult rv = NS_NewURI(getter_AddRefs(uri), fakeURL);
   NS_ENSURE_SUCCESS(rv, rv);
   rv = uri->GetAsciiHost(aAscii);
   NS_ENSURE_SUCCESS(rv, rv);