[epiphany/mcatanzaro/#1076] view-source-handler: don't lose port number when comparing views



commit 1118fc993555ee4cf01c7bf8bf5a410ed015744a
Author: Michael Catanzaro <mcatanzaro gnome org>
Date:   Wed Jan 29 10:38:11 2020 -0600

    view-source-handler: don't lose port number when comparing views
    
    We fail to find an existing tab displaying the target URI if it includes
    a non-default port, because soup_uri_set_scheme() resets the port to use
    the default for the given scheme.
    
    Credit to crvi for debugging.
    
    Fixes #1076

 embed/ephy-view-source-handler.c | 7 ++++++-
 src/window-commands.c            | 7 ++++++-
 2 files changed, 12 insertions(+), 2 deletions(-)
---
diff --git a/embed/ephy-view-source-handler.c b/embed/ephy-view-source-handler.c
index 43fb9be17..ada11c6c1 100644
--- a/embed/ephy-view-source-handler.c
+++ b/embed/ephy-view-source-handler.c
@@ -237,6 +237,7 @@ out:
 static void
 ephy_view_source_request_start (EphyViewSourceRequest *request)
 {
+  guint port;
   SoupURI *soup_uri;
   char *modified_uri;
   char *decoded_fragment;
@@ -260,9 +261,13 @@ ephy_view_source_request_start (EphyViewSourceRequest *request)
     return;
   }
 
-  /* Convert e.g. ephy-source://gnome.org#https to https://gnome.org */
+  /* Convert e.g. ephy-source://gnome.org#https to https://gnome.org, taking
+   * care to prevent soup_uri_set_scheme() from forcing the default port.
+   */
   decoded_fragment = soup_uri_decode (soup_uri->fragment);
+  port = soup_uri_get_port (soup_uri);
   soup_uri_set_scheme (soup_uri, decoded_fragment);
+  soup_uri_set_port (soup_uri, port);
   soup_uri_set_fragment (soup_uri, NULL);
   modified_uri = soup_uri_to_string (soup_uri, FALSE);
   g_assert (modified_uri);
diff --git a/src/window-commands.c b/src/window-commands.c
index 734383ba3..5f03fa253 100644
--- a/src/window-commands.c
+++ b/src/window-commands.c
@@ -1967,6 +1967,7 @@ window_cmd_page_source (GSimpleAction *action,
   SoupURI *soup_uri;
   char *source_uri;
   const char *address;
+  guint port;
 
   embed = ephy_embed_container_get_active_child
             (EPHY_EMBED_CONTAINER (window));
@@ -1984,9 +1985,13 @@ window_cmd_page_source (GSimpleAction *action,
     return;
   }
 
-  /* Convert e.g. https://gnome.org to ephy-source://gnome.org#https */
+  /* Convert e.g. https://gnome.org to ephy-source://gnome.org#https,
+   * taking care to prevent soup_uri_set_scheme() from forcing the default port.
+   */
+  port = soup_uri_get_port (soup_uri);
   soup_uri_set_fragment (soup_uri, soup_uri->scheme);
   soup_uri_set_scheme (soup_uri, EPHY_VIEW_SOURCE_SCHEME);
+  soup_uri_set_port (soup_uri, port);
   source_uri = soup_uri_to_string (soup_uri, FALSE);
 
   new_embed = ephy_shell_new_tab


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