Skip to content

Commit

Permalink
Dialog: XDG Portals: Remove the file:// URI
Browse files Browse the repository at this point in the history
  • Loading branch information
Semphris committed May 23, 2024
1 parent baacbeb commit 831a0d3
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/dialog/unix/SDL_portaldialog.c
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,8 @@ static DBusHandlerResult DBus_MessageFilter(DBusConnection *conn, DBusMessage *m

while (dbus->message_iter_get_arg_type(&uri_entry) == DBUS_TYPE_STRING)
{
const char *uri = NULL;

if (current >= length - 1) {
++length;
path = SDL_realloc(path, sizeof(const char *) * length);
Expand All @@ -234,7 +236,18 @@ static DBusHandlerResult DBus_MessageFilter(DBusConnection *conn, DBusMessage *m
goto cleanup;
}
}
dbus->message_iter_get_basic(&uri_entry, path + current);

dbus->message_iter_get_basic(&uri_entry, &uri);

/* https://flatpak.github.io/xdg-desktop-portal/docs/doc-org.freedesktop.portal.FileChooser.html */
/* Returned paths will always start with 'file://'; truncate it */
if (SDL_strncmp(uri, "file://", SDL_strlen("file://"))) {
path[current] = uri + SDL_strlen("file://");
} else if (SDL_strstr(uri, "://")) {
SDL_SetError("Portal dialogs: Unsupported protocol: %s", uri);
signal_data->callback(signal_data->userdata, NULL, -1);
goto cleanup;
}

dbus->message_iter_next(&uri_entry);
++current;
Expand Down

0 comments on commit 831a0d3

Please sign in to comment.