aboutsummaryrefslogtreecommitdiffstats
path: root/embed
diff options
context:
space:
mode:
Diffstat (limited to 'embed')
-rw-r--r--embed/mozilla/EphySingle.cpp29
-rw-r--r--embed/mozilla/mozilla-embed-single.cpp33
2 files changed, 56 insertions, 6 deletions
diff --git a/embed/mozilla/EphySingle.cpp b/embed/mozilla/EphySingle.cpp
index b8814d4e6..3c8fb67b6 100644
--- a/embed/mozilla/EphySingle.cpp
+++ b/embed/mozilla/EphySingle.cpp
@@ -33,6 +33,11 @@
#include <nsICookieManager.h>
#include <nsIServiceManager.h>
#include <nsICookie2.h>
+#include <nsIServiceManager.h>
+
+#ifdef ALLOW_PRIVATE_API
+#include <nsIIDNService.h>
+#endif
NS_IMPL_ISUPPORTS2(EphySingle, nsIObserver, nsISupportsWeakReference)
@@ -231,12 +236,23 @@ NS_IMETHODIMP EphySingle::Observe(nsISupports *aSubject,
EphyCookie *
mozilla_cookie_to_ephy_cookie (nsICookie *cookie)
{
- EphyCookie *info = ephy_cookie_new ();
+ EphyCookie *info;
nsEmbedCString transfer;
cookie->GetHost (transfer);
- info->domain = g_strdup (transfer.get());
+
+ nsCOMPtr<nsIIDNService> idnService
+ (do_GetService ("@mozilla.org/network/idn-service;1"));
+ NS_ENSURE_TRUE (idnService, nsnull);
+
+ nsEmbedCString decoded;
+ /* ToUTF8 never fails, no need to check return value */
+ idnService->ConvertACEtoUTF8 (transfer, decoded);
+
+ info = ephy_cookie_new ();
+ info->domain = g_strdup (decoded.get());
+
cookie->GetName (transfer);
info->name = g_strdup (transfer.get());
cookie->GetValue (transfer);
@@ -305,5 +321,12 @@ mozilla_permission_to_ephy_permission (nsIPermission *perm)
nsEmbedCString host;
perm->GetHost(host);
- return ephy_permission_info_new (host.get(), type.get(), permission);
+ nsCOMPtr<nsIIDNService> idnService
+ (do_GetService ("@mozilla.org/network/idn-service;1"));
+ NS_ENSURE_TRUE (idnService, nsnull);
+
+ nsEmbedCString decodedHost;
+ idnService->ConvertACEtoUTF8 (host, decodedHost);
+
+ return ephy_permission_info_new (decodedHost.get(), type.get(), permission);
}
diff --git a/embed/mozilla/mozilla-embed-single.cpp b/embed/mozilla/mozilla-embed-single.cpp
index 9556d8227..0ee08f9d4 100644
--- a/embed/mozilla/mozilla-embed-single.cpp
+++ b/embed/mozilla/mozilla-embed-single.cpp
@@ -78,6 +78,7 @@
#include <nsICacheService.h>
#include <nsIFontEnumerator.h>
#include <nsNetCID.h>
+#include <nsIIDNService.h>
#endif
#define MOZILLA_PROFILE_DIR "/mozilla"
@@ -655,6 +656,7 @@ impl_list_cookies (EphyCookieManager *manager)
if (NS_FAILED (result) || !keks) continue;
EphyCookie *cookie = mozilla_cookie_to_ephy_cookie (keks);
+ if (!cookie) continue;
cookies = g_list_prepend (cookies, cookie);
}
@@ -670,7 +672,16 @@ impl_remove_cookie (EphyCookieManager *manager,
do_GetService (NS_COOKIEMANAGER_CONTRACTID);
if (!cookieManager) return;
- cookieManager->Remove (nsEmbedCString(cookie->domain),
+ nsCOMPtr<nsIIDNService> idnService
+ (do_GetService ("@mozilla.org/network/idn-service;1"));
+ NS_ENSURE_TRUE (idnService, );
+
+ nsresult rv;
+ nsEmbedCString host;
+ rv = idnService->ConvertUTF8toACE (nsEmbedCString(cookie->domain), host);
+ NS_ENSURE_SUCCESS (rv, );
+
+ cookieManager->Remove (host,
nsEmbedCString(cookie->name),
nsEmbedCString(cookie->path),
PR_FALSE /* block */);
@@ -698,6 +709,10 @@ impl_list_passwords (EphyPasswordManager *manager)
do_GetService (NS_PASSWORDMANAGER_CONTRACTID);
if (!passwordManager) return NULL;
+ nsCOMPtr<nsIIDNService> idnService
+ (do_GetService ("@mozilla.org/network/idn-service;1"));
+ NS_ENSURE_TRUE (idnService, NULL);
+
nsCOMPtr<nsISimpleEnumerator> passwordEnumerator;
passwordManager->GetEnumerator (getter_AddRefs(passwordEnumerator));
NS_ENSURE_TRUE (passwordEnumerator, NULL);
@@ -715,6 +730,9 @@ impl_list_passwords (EphyPasswordManager *manager)
rv = nsPassword->GetHost (transfer);
if (NS_FAILED (rv)) continue;
+ nsEmbedCString host;
+ idnService->ConvertACEtoUTF8 (transfer, host);
+
nsEmbedString unicodeName;
rv = nsPassword->GetUser (unicodeName);
if (NS_FAILED (rv)) continue;
@@ -725,7 +743,7 @@ impl_list_passwords (EphyPasswordManager *manager)
EphyPasswordInfo *p = g_new0 (EphyPasswordInfo, 1);
- p->host = g_strdup (transfer.get());
+ p->host = g_strdup (host.get());
p->username = g_strdup (userName.get());
p->password = NULL;
@@ -744,10 +762,19 @@ impl_remove_password (EphyPasswordManager *manager,
do_GetService (NS_PASSWORDMANAGER_CONTRACTID);
if (!pm) return;
+ nsCOMPtr<nsIIDNService> idnService
+ (do_GetService ("@mozilla.org/network/idn-service;1"));
+ NS_ENSURE_TRUE (idnService, );
+
+ nsresult rv;
+ nsEmbedCString host;
+ rv = idnService->ConvertUTF8toACE (nsEmbedCString(info->host), host);
+ NS_ENSURE_SUCCESS (rv, );
+
nsEmbedString userName;
NS_CStringToUTF16 (nsEmbedCString(info->username),
NS_CSTRING_ENCODING_UTF8, userName);
- pm->RemoveUser (nsEmbedCString(info->host), userName);
+ pm->RemoveUser (host, userName);
}
static void