backends/monitor-manager: Validate EDID strings
Some monitors return a bunch of bytes on their display descriptor which aren't valid utf8 and thus we fail to serialize them later on for the DisplayConfig DBus API. Let's fall back to the stringified product code and serial number in that case. https://bugzilla.gnome.org/show_bug.cgi?id=752673
This commit is contained in:
parent
ad51c52b69
commit
2fb8da0d5a
@ -1416,25 +1416,35 @@ meta_output_parse_edid (MetaOutput *meta_output,
|
|||||||
if (parsed_edid)
|
if (parsed_edid)
|
||||||
{
|
{
|
||||||
meta_output->vendor = g_strndup (parsed_edid->manufacturer_code, 4);
|
meta_output->vendor = g_strndup (parsed_edid->manufacturer_code, 4);
|
||||||
if (parsed_edid->dsc_product_name[0])
|
if (!g_utf8_validate (meta_output->vendor, -1, NULL))
|
||||||
meta_output->product = g_strndup (parsed_edid->dsc_product_name, 14);
|
g_clear_pointer (&meta_output->vendor, g_free);
|
||||||
else
|
|
||||||
meta_output->product = g_strdup_printf ("0x%04x", (unsigned) parsed_edid->product_code);
|
meta_output->product = g_strndup (parsed_edid->dsc_product_name, 14);
|
||||||
if (parsed_edid->dsc_serial_number[0])
|
if (!g_utf8_validate (meta_output->product, -1, NULL) ||
|
||||||
meta_output->serial = g_strndup (parsed_edid->dsc_serial_number, 14);
|
meta_output->product[0] == '\0')
|
||||||
else
|
{
|
||||||
meta_output->serial = g_strdup_printf ("0x%08x", parsed_edid->serial_number);
|
g_clear_pointer (&meta_output->product, g_free);
|
||||||
|
meta_output->product = g_strdup_printf ("0x%04x", (unsigned) parsed_edid->product_code);
|
||||||
|
}
|
||||||
|
|
||||||
|
meta_output->serial = g_strndup (parsed_edid->dsc_serial_number, 14);
|
||||||
|
if (!g_utf8_validate (meta_output->serial, -1, NULL) ||
|
||||||
|
meta_output->serial[0] == '\0')
|
||||||
|
{
|
||||||
|
g_clear_pointer (&meta_output->serial, g_free);
|
||||||
|
meta_output->serial = g_strdup_printf ("0x%08x", parsed_edid->serial_number);
|
||||||
|
}
|
||||||
|
|
||||||
g_free (parsed_edid);
|
g_free (parsed_edid);
|
||||||
}
|
}
|
||||||
|
|
||||||
out:
|
out:
|
||||||
if (!meta_output->vendor)
|
if (!meta_output->vendor)
|
||||||
{
|
meta_output->vendor = g_strdup ("unknown");
|
||||||
meta_output->vendor = g_strdup ("unknown");
|
if (!meta_output->product)
|
||||||
meta_output->product = g_strdup ("unknown");
|
meta_output->product = g_strdup ("unknown");
|
||||||
meta_output->serial = g_strdup ("unknown");
|
if (!meta_output->serial)
|
||||||
}
|
meta_output->serial = g_strdup ("unknown");
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
Loading…
Reference in New Issue
Block a user