diff options
Diffstat (limited to 'chromium/ui/display/util')
-rw-r--r-- | chromium/ui/display/util/edid_parser.cc | 12 | ||||
-rw-r--r-- | chromium/ui/display/util/edid_parser_unittest.cc | 30 |
2 files changed, 34 insertions, 8 deletions
diff --git a/chromium/ui/display/util/edid_parser.cc b/chromium/ui/display/util/edid_parser.cc index 4664a3e5332..d1b248b92ed 100644 --- a/chromium/ui/display/util/edid_parser.cc +++ b/chromium/ui/display/util/edid_parser.cc @@ -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 diff --git a/chromium/ui/display/util/edid_parser_unittest.cc b/chromium/ui/display/util/edid_parser_unittest.cc index 0991d79c751..73dda4af53c 100644 --- a/chromium/ui/display/util/edid_parser_unittest.cc +++ b/chromium/ui/display/util/edid_parser_unittest.cc @@ -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" @@ -251,6 +263,24 @@ struct TestParams { } 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", gfx::Size(2560, 1600), 2012, |