summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Catanzaro <mcatanzaro@redhat.com>2022-11-14 15:32:21 -0600
committerMarge Bot <marge-bot@gnome.org>2022-11-15 12:56:23 +0000
commit18cc88d30b8ddd45fdd1276b916b0e56bb57b37f (patch)
tree8cffd59a556ea95fee2f4b1b73573374150efe65
parentdc078d01b51e8fea6f44c78f0a6cafbf8fcaccf5 (diff)
downloadepiphany-18cc88d30b8ddd45fdd1276b916b0e56bb57b37f.tar.gz
location-controller: fix crash when ephy-tab URI is invalid
Here the code assumes that the URI is a valid ephy-tab:// URI, but in fact this is not guaranteed because the URI is user input. Instead of crashing when it's wrong, we need to ignore it. This halfway fixes #1907. Part-of: <https://gitlab.gnome.org/GNOME/epiphany/-/merge_requests/1220>
-rw-r--r--src/ephy-location-controller.c40
1 files changed, 20 insertions, 20 deletions
diff --git a/src/ephy-location-controller.c b/src/ephy-location-controller.c
index 8c2ab39c6..46de7174d 100644
--- a/src/ephy-location-controller.c
+++ b/src/ephy-location-controller.c
@@ -98,33 +98,33 @@ entry_activate_cb (EphyLocationEntry *entry,
EphyWebView *webview;
g_auto (GStrv) split = g_strsplit (content + strlen ("ephy-tab://"), "@", -1);
- g_assert (g_strv_length (split) == 2);
+ if (g_strv_length (split) == 2) {
+ tab = ephy_tab_view_get_selected_page (tab_view);
+ webview = ephy_embed_get_web_view (EPHY_EMBED (tab));
- tab = ephy_tab_view_get_selected_page (tab_view);
- webview = ephy_embed_get_web_view (EPHY_EMBED (tab));
+ if (atoi (split[1]) != 0) {
+ GApplication *application;
+ EphyEmbedShell *shell;
+ EphyWindow *window;
+ GList *windows;
- if (atoi (split[1]) != 0) {
- GApplication *application;
- EphyEmbedShell *shell;
- EphyWindow *window;
- GList *windows;
+ shell = ephy_embed_shell_get_default ();
+ application = G_APPLICATION (shell);
+ windows = gtk_application_get_windows (GTK_APPLICATION (application));
- shell = ephy_embed_shell_get_default ();
- application = G_APPLICATION (shell);
- windows = gtk_application_get_windows (GTK_APPLICATION (application));
+ window = g_list_nth_data (windows, atoi (split[1]));
+ tab_view = ephy_window_get_tab_view (window);
- window = g_list_nth_data (windows, atoi (split[1]));
- tab_view = ephy_window_get_tab_view (window);
+ gtk_window_present (GTK_WINDOW (window));
+ }
- gtk_window_present (GTK_WINDOW (window));
- }
-
- ephy_tab_view_select_nth_page (tab_view, atoi (split[0]));
+ ephy_tab_view_select_nth_page (tab_view, atoi (split[0]));
- if (ephy_web_view_is_overview (webview))
- ephy_tab_view_close (tab_view, tab);
+ if (ephy_web_view_is_overview (webview))
+ ephy_tab_view_close (tab_view, tab);
- return;
+ return;
+ }
}
address = g_strdup (content);