[gnome-builder] flatpak: check for useful app-id
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] flatpak: check for useful app-id
- Date: Tue, 30 Jan 2018 13:05:26 +0000 (UTC)
commit cfad0f6cf5da75e8eaa941ba8074b8c888eaa034
Author: Christian Hergert <chergert redhat com>
Date: Tue Jan 30 05:04:36 2018 -0800
flatpak: check for useful app-id
We may need to extend this check to be more inclusive.
.../flatpak/gbp-flatpak-configuration-provider.c | 8 --------
src/plugins/flatpak/gbp-flatpak-manifest.c | 23 ++++++++++++++++++++--
2 files changed, 21 insertions(+), 10 deletions(-)
---
diff --git a/src/plugins/flatpak/gbp-flatpak-configuration-provider.c
b/src/plugins/flatpak/gbp-flatpak-configuration-provider.c
index 4812199ad..b94d6ff72 100644
--- a/src/plugins/flatpak/gbp-flatpak-configuration-provider.c
+++ b/src/plugins/flatpak/gbp-flatpak-configuration-provider.c
@@ -33,10 +33,6 @@ struct _GbpFlatpakConfigurationProvider
GPtrArray *configs;
};
-
-
-static GRegex *filename_regex;
-
static void
gbp_flatpak_configuration_provider_save_worker (GTask *task,
gpointer source_object,
@@ -334,10 +330,6 @@ gbp_flatpak_configuration_provider_class_init (GbpFlatpakConfigurationProviderCl
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->finalize = gbp_flatpak_configuration_provider_finalize;
-
- /* This regex is based on https://wiki.gnome.org/HowDoI/ChooseApplicationID */
- filename_regex = g_regex_new ("^[[:alnum:]-_]+\\.[[:alnum:]-_]+(\\.[[:alnum:]-_]+)*\\.json$",
- G_REGEX_OPTIMIZE, 0, NULL);
}
static void
diff --git a/src/plugins/flatpak/gbp-flatpak-manifest.c b/src/plugins/flatpak/gbp-flatpak-manifest.c
index ee4d2fe8c..cf91d34b8 100644
--- a/src/plugins/flatpak/gbp-flatpak-manifest.c
+++ b/src/plugins/flatpak/gbp-flatpak-manifest.c
@@ -66,6 +66,13 @@ enum {
};
static GParamSpec *properties [N_PROPS];
+static GRegex *app_id_regex;
+
+static gboolean
+is_valid_app_id (const gchar *str)
+{
+ return g_regex_match (app_id_regex, str, 0, NULL);
+}
static gboolean
validate_properties (GbpFlatpakManifest *self,
@@ -369,8 +376,16 @@ gbp_flatpak_manifest_initable_init (GInitable *initable,
if (!(primary = discover_primary_module (self, root_obj, dir_name, TRUE, error)))
return FALSE;
- if (discover_string_field (root_obj, "app-id", &app_id))
- ide_configuration_set_app_id (IDE_CONFIGURATION (self), app_id);
+ if (!discover_string_field (root_obj, "app-id", &app_id) || !is_valid_app_id (app_id))
+ {
+ g_set_error (error,
+ G_IO_ERROR,
+ G_IO_ERROR_INVALID_DATA,
+ "File does not appear to have a valid app-id");
+ return FALSE;
+ }
+
+ ide_configuration_set_app_id (IDE_CONFIGURATION (self), app_id);
discover_string_field (root_obj, "runtime", &self->runtime);
discover_string_field (root_obj, "runtime-version", &self->runtime_version);
@@ -530,6 +545,10 @@ gbp_flatpak_manifest_class_init (GbpFlatpakManifestClass *klass)
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS);
g_object_class_install_properties (object_class, N_PROPS, properties);
+
+ /* This regex is based on https://wiki.gnome.org/HowDoI/ChooseApplicationID */
+ app_id_regex = g_regex_new ("^[[:alnum:]-_]+\\.[[:alnum:]-_]+(\\.[[:alnum:]-_]+)*$",
+ G_REGEX_OPTIMIZE, 0, NULL);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]