diff options
author | Matthias Clasen <mclasen@redhat.com> | 2023-05-11 18:33:23 -0400 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2023-05-11 18:34:26 -0400 |
commit | 85b9a6f1b0f8c3b4cd74727e94635dbce2970e8b (patch) | |
tree | 14a792763a6d44bbfb5afe43dd551603239141e3 | |
parent | 3353eac2895f514e6247b2ee155f62ea588795a5 (diff) | |
download | gtk+-85b9a6f1b0f8c3b4cd74727e94635dbce2970e8b.tar.gz |
urilauncher: Validate the uri
We don't want to send nonsense to the portal.
Fixes: #5829
-rw-r--r-- | gtk/gtkurilauncher.c | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/gtk/gtkurilauncher.c b/gtk/gtkurilauncher.c index bf6e2e260b..7410a8da2a 100644 --- a/gtk/gtkurilauncher.c +++ b/gtk/gtkurilauncher.c @@ -277,13 +277,14 @@ G_GNUC_END_IGNORE_DEPRECATIONS * Since: 4.10 */ void -gtk_uri_launcher_launch (GtkUriLauncher *self, - GtkWindow *parent, - GCancellable *cancellable, - GAsyncReadyCallback callback, - gpointer user_data) +gtk_uri_launcher_launch (GtkUriLauncher *self, + GtkWindow *parent, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data) { GTask *task; + GError *error = NULL; g_return_if_fail (GTK_IS_URI_LAUNCHER (self)); @@ -299,6 +300,15 @@ gtk_uri_launcher_launch (GtkUriLauncher *self, return; } + if (!g_uri_is_valid (self->uri, G_URI_FLAGS_NONE, &error)) + { + g_task_return_new_error (task, + GTK_DIALOG_ERROR, GTK_DIALOG_ERROR_FAILED, + "%s is not a valid uri: %s", self->uri, error->message); + g_error_free (error); + return; + } + #ifndef G_OS_WIN32 if (gtk_openuri_portal_is_available ()) gtk_openuri_portal_open_uri_async (self->uri, parent, cancellable, open_done, task); @@ -325,8 +335,8 @@ G_GNUC_END_IGNORE_DEPRECATIONS */ gboolean gtk_uri_launcher_launch_finish (GtkUriLauncher *self, - GAsyncResult *result, - GError **error) + GAsyncResult *result, + GError **error) { g_return_val_if_fail (GTK_IS_URI_LAUNCHER (self), FALSE); g_return_val_if_fail (g_task_is_valid (result, self), FALSE); |