mirror of
https://github.com/microsoft/vcpkg.git
synced 2024-12-28 19:25:27 +08:00
Fix a infinite skip_comment check in Paragraphs.cpp
This happens when git not checkout file's line break as CR-LF. When CONTROL file contains comment followed by \n instead of \r\n, there will be a infinite skip_comment check.
This commit is contained in:
parent
d9a4034539
commit
928ff24cbc
@ -34,7 +34,7 @@ namespace vcpkg::Paragraphs
|
||||
|
||||
void skip_comment(char& ch)
|
||||
{
|
||||
while (ch != '\r')
|
||||
while (ch != '\r' && ch != '\n' && ch != '\0')
|
||||
next(ch);
|
||||
if (ch == '\r')
|
||||
next(ch);
|
||||
|
@ -289,6 +289,16 @@ namespace UnitTest1
|
||||
Assert::AreEqual("v4", pghs[1]["f4"].c_str());
|
||||
}
|
||||
|
||||
TEST_METHOD(parse_comment_before_single_slashN)
|
||||
{
|
||||
const char* str =
|
||||
"f1: v1\r\n"
|
||||
"#comment\n";
|
||||
auto pghs = vcpkg::Paragraphs::parse_paragraphs(str).value_or_exit(VCPKG_LINE_INFO);
|
||||
Assert::AreEqual(size_t(1), pghs[0].size());
|
||||
Assert::AreEqual("v1", pghs[0]["f1"].c_str());
|
||||
}
|
||||
|
||||
TEST_METHOD(BinaryParagraph_serialize_min)
|
||||
{
|
||||
std::stringstream ss;
|
||||
|
Loading…
x
Reference in New Issue
Block a user