[epiphany] webapp: Open links to the same base domain inside the web app



commit 0b4464039e0e1175abd0f90e2700631991d643c0
Author: Carlos Garcia Campos <cgarcia igalia com>
Date:   Sat Jun 27 10:41:59 2015 +0200

    webapp: Open links to the same base domain inside the web app
    
    This fixes the case of web apps like www.foo.com that have a login
    button that loads login.foo.com. Since we are just checking the hosts,
    they are different, and the login page is opened in a different browser
    or profile, making it impossible to login inside the web app. Now, when
    the hosts are different we also check the base domain, using
    soup_tld_get_base_domain().

 embed/ephy-embed-utils.c |   20 +++++++++++++++++---
 1 files changed, 17 insertions(+), 3 deletions(-)
---
diff --git a/embed/ephy-embed-utils.c b/embed/ephy-embed-utils.c
index 6f2eb77..e58f3a7 100644
--- a/embed/ephy-embed-utils.c
+++ b/embed/ephy-embed-utils.c
@@ -322,12 +322,26 @@ ephy_embed_utils_urls_have_same_origin (const char *a_url,
     return retval;
 
   b_uri = soup_uri_new (b_url);
-  if (b_uri) {
-    retval = a_uri->host && b_uri->host && soup_uri_host_equal (a_uri, b_uri);
-    soup_uri_free (b_uri);
+  if (!b_uri) {
+    soup_uri_free (a_uri);
+    return retval;
+  }
+
+  if (a_uri->host && b_uri->host) {
+    retval = soup_uri_host_equal (a_uri, b_uri);
+    if (!retval) {
+      const char *a_domain;
+      const char *b_domain;
+
+      a_domain = soup_tld_get_base_domain (a_uri->host, NULL);
+      b_domain = soup_tld_get_base_domain (b_uri->host, NULL);
+
+      retval = a_domain && b_domain && strcmp (a_domain, b_domain) == 0;
+    }
   }
 
   soup_uri_free (a_uri);
+  soup_uri_free (b_uri);
 
   return retval;
 }


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