trivial: Strip leading and trailing spaces from the vendor name

This commit is contained in:
Richard Hughes 2022-02-24 16:07:59 +00:00
parent e3583793ed
commit adfef91731
2 changed files with 9 additions and 2 deletions

View File

@ -2255,7 +2255,14 @@ fu_device_fixup_vendor_name(FuDevice *self)
void
fu_device_set_vendor(FuDevice *self, const gchar *vendor)
{
fwupd_device_set_vendor(FWUPD_DEVICE(self), vendor);
g_autofree gchar *vendor_safe = NULL;
/* trim any leading and trailing spaces */
if (vendor != NULL)
vendor_safe = fu_common_strstrip(vendor);
/* proxy */
fwupd_device_set_vendor(FWUPD_DEVICE(self), vendor_safe);
fu_device_fixup_vendor_name(self);
}

View File

@ -263,7 +263,7 @@ fu_device_name_func(void)
g_autoptr(FuDevice) device2 = fu_device_new();
/* vendor then name */
fu_device_set_vendor(device1, "Hughski");
fu_device_set_vendor(device1, " Hughski ");
fu_device_set_name(device1, "HUGHSKI ColorHug(TM)__Pro ");
g_assert_cmpstr(fu_device_get_vendor(device1), ==, "Hughski");
g_assert_cmpstr(fu_device_get_name(device1), ==, "ColorHug™ Pro");