Skip to content

Commit

Permalink
appdata: exclude <name> element inside <developer>
Browse files Browse the repository at this point in the history
<developer_name> has been deprecated in favor of <developer> with a
<name> child. We need to ensure that this developer name isn't parsed
as the application name.

Fixes: #5700
  • Loading branch information
chrisawi authored and TingPing committed Mar 12, 2024
1 parent 2cb17b4 commit 73d4a3b
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions common/flatpak-appdata.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ typedef struct
gboolean in_text;
gboolean in_component;
gboolean in_content_rating;
gboolean in_developer;
char *lang;
guint64 timestamp;
const char *id; /* interned */
Expand Down Expand Up @@ -119,7 +120,7 @@ start_element (GMarkupParseContext *context,
{
data->in_text = TRUE;
}
else if (g_str_equal (element_name, "name") ||
else if ((!data->in_developer && g_str_equal (element_name, "name")) ||
g_str_equal (element_name, "summary"))
{
const char *lang = NULL;
Expand Down Expand Up @@ -259,6 +260,10 @@ start_element (GMarkupParseContext *context,
g_warning ("Ignoring content attribute missing id attribute");
}
}
else if (g_str_equal (element_name, "developer"))
{
data->in_developer = TRUE;
}
}

static void
Expand Down Expand Up @@ -294,7 +299,7 @@ end_element (GMarkupParseContext *context,
{
component->id = g_steal_pointer (&text);
}
else if (g_str_equal (element_name, "name"))
else if (!data->in_developer && g_str_equal (element_name, "name"))
{
g_hash_table_insert (component->names, g_steal_pointer (&data->lang), g_steal_pointer (&text));
}
Expand All @@ -316,6 +321,10 @@ end_element (GMarkupParseContext *context,
g_assert (component->content_rating != NULL);
g_hash_table_insert (component->content_rating, (gpointer) data->id, (gpointer) g_intern_string (text));
}
else if (g_str_equal (element_name, "developer"))
{
data->in_developer = FALSE;
}
}

static void
Expand Down

0 comments on commit 73d4a3b

Please sign in to comment.