Commit 65be92ea authored by Sasha McIntosh's avatar Sasha McIntosh Committed by Commit Bot

display: Modify display name error handling

In cases where a single character in a display name is non-printable, we
use an empty string for the display name. This change instead replaces a
non-printable char with a space.

Added test case for a string with non-printable char. Note that the
display_id is generated from the display name, so this is also updated
in the test.

Change-Id: I8092bf10bdf5c93b450a0bf84b18c5aaae157452
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2212701
Commit-Queue: Sasha McIntosh <sashamcintosh@chromium.org>
Reviewed-by: default avatarDaniele Castagna <dcastagna@chromium.org>
Cr-Commit-Position: refs/heads/master@{#771996}
parent b7d9656d
......@@ -328,14 +328,10 @@ void EdidParser::ParseEdid(const std::vector<uint8_t>& edid) {
}
// Verify if the |display_name_| consists of printable characters only.
// TODO(oshima|muka): Consider replacing unprintable chars with white space.
for (const char c : display_name_) {
if (!isascii(c) || !isprint(c)) {
display_name_.clear();
base::UmaHistogramEnumeration(kParseEdidFailureMetric,
ParseEdidFailure::kDisplayName);
}
}
// Replace unprintable chars with white space.
std::replace_if(
display_name_.begin(), display_name_.end(),
[](char c) { return !isascii(c) || !isprint(c); }, ' ');
// See http://en.wikipedia.org/wiki/Extended_display_identification_data
// for the extension format of EDID. Also see EIA/CEA-861 spec for
......
......@@ -25,6 +25,18 @@ namespace display {
namespace {
// EDID with non-ascii char in display name.
constexpr unsigned char kBadDisplayName[] =
"\x00\xff\xff\xff\xff\xff\xff\x00\x22\xf0\x6c\x28\x01\x01\x01\x01"
"\x02\x16\x01\x04\xb5\x40\x28\x78\xe2\x8d\x85\xad\x4f\x35\xb1\x25"
"\x0e\x50\x54\x00\x00\x00\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01"
"\x01\x01\x01\x01\x01\x01\xe2\x68\x00\xa0\xa0\x40\x2e\x60\x30\x20"
"\x36\x00\x81\x90\x21\x00\x00\x1a\xbc\x1b\x00\xa0\x50\x20\x17\x30"
"\x30\x20\x36\x00\x81\x90\x21\x00\x00\x1a\x00\x00\x00\xfc\x00\x48"
"\x50\x20\x5a\x00\x33\x30\x77\x0a\x20\x20\x20\x20\x00\x00\x00\xff"
"\x00\x43\x4e\x34\x32\x30\x32\x31\x33\x37\x51\x0a\x20\x20\x00\x71";
constexpr size_t kBadDisplayNameLength = base::size(kBadDisplayName);
// Sample EDID data extracted from real devices.
constexpr unsigned char kNormalDisplay[] =
"\x00\xff\xff\xff\xff\xff\xff\x00\x22\xf0\x6c\x28\x01\x01\x01\x01"
......@@ -249,6 +261,24 @@ struct TestParams {
const unsigned char* edid_blob;
size_t edid_blob_length;
} kTestCases[] = {
{0x22f0u,
0x6c28u,
"HP Z 30w", // non-ascii char in display name.
gfx::Size(2560, 1600),
2012,
false,
2.2,
10,
kNormalDisplayPrimaries,
586181672,
9834990092472576,
"HWP",
"286C",
{},
{},
base::nullopt,
kBadDisplayName,
kBadDisplayNameLength},
{0x22f0u,
0x6c28u,
"HP ZR30w",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment