[epiphany/gnome-3-16] webapp: Open links to the same base domain inside the web app



commit 121b541924c4c0e9927170e285eebe0c2571d941
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 a43cee9..28cd2f5 100644
--- a/embed/ephy-embed-utils.c
+++ b/embed/ephy-embed-utils.c
@@ -315,12 +315,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]