mirror of
https://github.com/flatpak/flatpak.git
synced 2026-10-21 23:25:33 -04:00
Handle uris better when detecting .flatpak[repo,ref] suffix
We fully parse the argument as (possibly) a uri, which means we can handle an argument like: https://git.gnome.org/browse/gnome-apps-nightly/plain/gnome-builder.flatpakref?h=stable Which doesn't work with a simple has_suffix call. This is important because the flatpak.org site now references these kinds of uris. Fixes https://github.com/flatpak/flatpak/issues/659
This commit is contained in:
1 parent
3ff6d312de
commit
0dcc7332f7
4 files changed
+15
-3
No files matched your search
@@ -403,7 +403,7 @@ flatpak_builtin_add_remote (int argc, char **argv,
|
||||
}
|
||||
|
||||
if (opt_from ||
|
||||
g_str_has_suffix (location, ".flatpakrepo"))
|
||||
flatpak_file_arg_has_suffix (location, ".flatpakrepo"))
|
||||
{
|
||||
load_options (location, &gpg_data);
|
||||
if (opt_url == NULL)
|
||||
|
||||
@@ -375,6 +375,7 @@ install_from (FlatpakDir *dir,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
gboolean
|
||||
flatpak_builtin_install (int argc, char **argv, GCancellable *cancellable, GError **error)
|
||||
{
|
||||
@@ -396,9 +397,9 @@ flatpak_builtin_install (int argc, char **argv, GCancellable *cancellable, GErro
|
||||
|
||||
if (!opt_bundle && !opt_from && argc >= 2)
|
||||
{
|
||||
if (g_str_has_suffix (argv[1], ".flatpakref"))
|
||||
if (flatpak_file_arg_has_suffix (argv[1], ".flatpakref"))
|
||||
opt_from = TRUE;
|
||||
if (g_str_has_suffix (argv[1], ".flatpak"))
|
||||
if (flatpak_file_arg_has_suffix (argv[1], ".flatpak"))
|
||||
opt_bundle = TRUE;
|
||||
}
|
||||
|
||||
|
||||
@@ -1924,6 +1924,16 @@ flatpak_quote_argv (const char *argv[])
|
||||
return g_string_free (res, FALSE);
|
||||
}
|
||||
|
||||
/* This is useful, because it handles escaped characters in uris, and ? arguments at the end of the uri */
|
||||
gboolean
|
||||
flatpak_file_arg_has_suffix (const char *arg, const char *suffix)
|
||||
{
|
||||
g_autoptr(GFile) file = g_file_new_for_commandline_arg (arg);
|
||||
g_autofree char *basename = g_file_get_basename (file);
|
||||
|
||||
return g_str_has_suffix (basename, suffix);
|
||||
}
|
||||
|
||||
gboolean
|
||||
flatpak_spawn (GFile *dir,
|
||||
char **output,
|
||||
|
||||
@@ -383,6 +383,7 @@ GList *flatpak_list_extensions (GKeyFile *metakey,
|
||||
const char *branch);
|
||||
|
||||
char * flatpak_quote_argv (const char *argv[]);
|
||||
gboolean flatpak_file_arg_has_suffix (const char *arg, const char *suffix);
|
||||
|
||||
gboolean flatpak_spawn (GFile *dir,
|
||||
char **output,
|
||||
|
||||
Reference in new issue
Block a user