mirror of
https://git.proxmox.com/git/fwupd
synced 2025-08-13 19:37:17 +00:00
Strip inner XML text when loading metainfo.xml files
This allows us to do the right thing if given an XML file with leading or trailing space in the entry, e.g. <value key=LVFS::UpdateProtocol> org.uefi.capsule </value>
This commit is contained in:
parent
bc14f4c59c
commit
e99dd242e9
@ -494,6 +494,19 @@ fu_cabinet_set_lowercase_checksum_cb(XbBuilderFixup *builder_fixup,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
fu_cabinet_fixup_strip_inner_text_cb(XbBuilderFixup *self,
|
||||
XbBuilderNode *bn,
|
||||
gpointer user_data,
|
||||
GError **error)
|
||||
{
|
||||
#if LIBXMLB_CHECK_VERSION(0, 3, 4)
|
||||
if (xb_builder_node_get_first_child(bn) == NULL)
|
||||
xb_builder_node_add_flag(bn, XB_BUILDER_NODE_FLAG_STRIP_TEXT);
|
||||
#endif
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* adds each GCabFile to the silo */
|
||||
static gboolean
|
||||
fu_cabinet_build_silo_file(FuCabinet *self,
|
||||
@ -628,6 +641,7 @@ fu_cabinet_build_silo(FuCabinet *self, GBytes *data, GError **error)
|
||||
g_autoptr(XbBuilderFixup) fixup1 = NULL;
|
||||
g_autoptr(XbBuilderFixup) fixup2 = NULL;
|
||||
g_autoptr(XbBuilderFixup) fixup3 = NULL;
|
||||
g_autoptr(XbBuilderFixup) fixup4 = NULL;
|
||||
|
||||
/* verbose profiling */
|
||||
if (g_getenv("FWUPD_XMLB_VERBOSE") != NULL) {
|
||||
@ -671,6 +685,13 @@ fu_cabinet_build_silo(FuCabinet *self, GBytes *data, GError **error)
|
||||
NULL);
|
||||
xb_builder_add_fixup(self->builder, fixup3);
|
||||
|
||||
/* strip inner nodes without children */
|
||||
fixup4 = xb_builder_fixup_new("TextStripInner",
|
||||
fu_cabinet_fixup_strip_inner_text_cb,
|
||||
self,
|
||||
NULL);
|
||||
xb_builder_add_fixup(self->builder, fixup4);
|
||||
|
||||
/* did we get any valid files */
|
||||
self->silo = xb_builder_compile(self->builder, XB_BUILDER_COMPILE_FLAG_NONE, NULL, error);
|
||||
if (self->silo == NULL)
|
||||
|
Loading…
Reference in New Issue
Block a user