From 2ec80a5b8487d7d4dc1b663aa2705c812aeff5a1 Mon Sep 17 00:00:00 2001 From: Evgeni Margolis Date: Fri, 13 Jan 2023 16:17:55 -0800 Subject: [PATCH] Addressed review comments --- src/lib/core/TLVReader.cpp | 8 ++++---- src/lib/core/tests/TestTLV.cpp | 1 + 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/lib/core/TLVReader.cpp b/src/lib/core/TLVReader.cpp index 45f186a68d75cc..c4537f945f97f3 100644 --- a/src/lib/core/TLVReader.cpp +++ b/src/lib/core/TLVReader.cpp @@ -300,7 +300,7 @@ CHIP_ERROR TLVReader::Get(ByteSpan & v) CHIP_ERROR TLVReader::Get(CharSpan & v) { - constexpr int kAsciiUnitSeparator = 0x1F; + constexpr int kUnicodeInformationSeparator1 = 0x1F; if (!TLVTypeIsUTF8String(ElementType())) { @@ -312,9 +312,9 @@ CHIP_ERROR TLVReader::Get(CharSpan & v) uint32_t len = GetLength(); - // If ASCII Unit Separator (0x1f) is present in the string then method returns string ending - // at first appearance of Unit Separator. - const uint8_t * unitSeparator = reinterpret_cast(memchr(bytes, kAsciiUnitSeparator, len)); + // If Unicode Information Separator 1 (0x1f) is present in the string then method returns + // string ending at first appearance of the Information Separator 1. + const uint8_t * unitSeparator = reinterpret_cast(memchr(bytes, kUnicodeInformationSeparator1, len)); if (unitSeparator != nullptr) { len = static_cast(unitSeparator - bytes); diff --git a/src/lib/core/tests/TestTLV.cpp b/src/lib/core/tests/TestTLV.cpp index 4f3c39f36ce57e..ec38b9463ecda7 100644 --- a/src/lib/core/tests/TestTLV.cpp +++ b/src/lib/core/tests/TestTLV.cpp @@ -2804,6 +2804,7 @@ void CheckTLVCharSpan(nlTestSuite * inSuite, void * inContext) { "This is a test case #0", "This is a test case #0" }, { "This is a test case #1\x1fTest Localized String Identifier", "This is a test case #1" }, { "This is a test case #2 \x1f abc \x1f def", "This is a test case #2 " }, + { "This is a test case #3\x1f", "This is a test case #3" }, }; // clang-format on