Skip to content

Commit

Permalink
Addressed review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
emargolis committed Jan 14, 2023
1 parent f3cf127 commit 2ec80a5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/lib/core/TLVReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()))
{
Expand All @@ -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<const uint8_t *>(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<const uint8_t *>(memchr(bytes, kUnicodeInformationSeparator1, len));
if (unitSeparator != nullptr)
{
len = static_cast<uint32_t>(unitSeparator - bytes);
Expand Down
1 change: 1 addition & 0 deletions src/lib/core/tests/TestTLV.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 2ec80a5

Please sign in to comment.