diff options
author | Richard Hughes <richard@hughsie.com> | 2015-01-20 21:03:19 +0000 |
---|---|---|
committer | Richard Hughes <richard@hughsie.com> | 2015-01-21 09:06:53 +0000 |
commit | 37db70de4f4044da80c874252cf31b80c5e15871 (patch) | |
tree | 1281efd760714ffa095c4a7bc64a57b017876dee /libappstream-glib/as-release.c | |
parent | 9b96be71a85b9e12a43fee3642fd71957d6b0bdf (diff) | |
download | appstream-glib-37db70de4f4044da80c874252cf31b80c5e15871.tar.gz |
Correctly load descriptions from <releases> in AppData files
Diffstat (limited to 'libappstream-glib/as-release.c')
-rw-r--r-- | libappstream-glib/as-release.c | 32 |
1 files changed, 23 insertions, 9 deletions
diff --git a/libappstream-glib/as-release.c b/libappstream-glib/as-release.c index 6b16c61..f4f40c9 100644 --- a/libappstream-glib/as-release.c +++ b/libappstream-glib/as-release.c @@ -276,16 +276,30 @@ as_release_node_parse (AsRelease *release, GNode *node, priv->version = taken; } - /* descriptions are translated and optional */ - for (n = node->children; n != NULL; n = n->next) { - _cleanup_string_free_ GString *xml = NULL; - if (as_node_get_tag (n) != AS_TAG_DESCRIPTION) - continue; - xml = as_node_to_xml (n->children, AS_NODE_TO_XML_FLAG_NONE); - as_release_set_description (release, - as_node_get_attribute (n, "xml:lang"), - xml->str, xml->len); + /* AppStream: multiple <description> tags */ + if (as_node_context_get_source_kind (ctx) == AS_APP_SOURCE_KIND_APPSTREAM) { + for (n = node->children; n != NULL; n = n->next) { + _cleanup_string_free_ GString *xml = NULL; + if (as_node_get_tag (n) != AS_TAG_DESCRIPTION) + continue; + xml = as_node_to_xml (n->children, AS_NODE_TO_XML_FLAG_NONE); + as_release_set_description (release, + as_node_get_attribute (n, "xml:lang"), + xml->str, xml->len); + } + + /* AppData: mutliple languages encoded in one <description> tag */ + } else { + n = as_node_find (node, "description"); + if (n != NULL) { + if (priv->descriptions != NULL) + g_hash_table_unref (priv->descriptions); + priv->descriptions = as_node_get_localized_unwrap (n, error); + if (priv->descriptions == NULL) + return FALSE; + } } + return TRUE; } |