mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-08-22 17:08:53 +02:00
glib-compile-schema: Don't accept duplicate docs
This schema compiler was completely ignoring <summary> and <description> tags. Unfortunately, there are modules out there who merge translations for these back in, with xml:lang. And this is giving dconf-editor a hard time. Since this is not how translations of schemas are meant to be done, just reject such schema files. Also add tests exercising the new error handling. https://bugzilla.gnome.org/show_bug.cgi?id=747209
This commit is contained in:
@@ -192,6 +192,9 @@ typedef struct
|
||||
|
||||
gboolean checked;
|
||||
GVariant *serialised;
|
||||
|
||||
gboolean summary_seen;
|
||||
gboolean description_seen;
|
||||
} KeyState;
|
||||
|
||||
static KeyState *
|
||||
@@ -208,6 +211,8 @@ key_state_new (const gchar *type_string,
|
||||
state->have_gettext_domain = gettext_domain != NULL;
|
||||
state->is_enum = is_enum;
|
||||
state->is_flags = is_flags;
|
||||
state->summary_seen = FALSE;
|
||||
state->description_seen = FALSE;
|
||||
|
||||
if (strinfo)
|
||||
state->strinfo = g_string_new_len (strinfo->str, strinfo->len);
|
||||
@@ -1374,9 +1379,27 @@ start_element (GMarkupParseContext *context,
|
||||
return;
|
||||
}
|
||||
|
||||
else if (strcmp (element_name, "summary") == 0 ||
|
||||
strcmp (element_name, "description") == 0)
|
||||
else if (strcmp (element_name, "summary") == 0)
|
||||
{
|
||||
if (state->key_state->summary_seen)
|
||||
g_set_error (error, G_MARKUP_ERROR, G_MARKUP_ERROR_INVALID_CONTENT,
|
||||
_("Only one <%s> element allowed inside <%s>"),
|
||||
element_name, container);
|
||||
state->key_state->summary_seen = TRUE;
|
||||
|
||||
if (NO_ATTRS ())
|
||||
state->string = g_string_new (NULL);
|
||||
return;
|
||||
}
|
||||
|
||||
else if (strcmp (element_name, "description") == 0)
|
||||
{
|
||||
if (state->key_state->description_seen)
|
||||
g_set_error (error, G_MARKUP_ERROR, G_MARKUP_ERROR_INVALID_CONTENT,
|
||||
_("Only one <%s> element allowed inside <%s>"),
|
||||
element_name, container);
|
||||
state->key_state->description_seen = TRUE;
|
||||
|
||||
if (NO_ATTRS ())
|
||||
state->string = g_string_new (NULL);
|
||||
return;
|
||||
|
Reference in New Issue
Block a user