Remove \r\n for \n when writing to ostream (#24980)
This commit is contained in:
parent
2ad1b6d835
commit
cdb3cbd620
|
|
@ -77,7 +77,18 @@ void FileRedirectionOutput::Append(const std::wstring& text)
|
|||
{
|
||||
if (m_file.is_open())
|
||||
{
|
||||
const auto multiByte = to_multi_byte_string(text, CP_UTF8);
|
||||
auto multiByte = to_multi_byte_string(text, CP_UTF8);
|
||||
|
||||
// Writing \r\n to an ostream will cause two new lines to be written rather
|
||||
// than one. Change all \r\n to \n.
|
||||
std::string slashRslashN = "\r\n";
|
||||
std::string slashN = "\n";
|
||||
size_t start_pos = 0;
|
||||
while ((start_pos = multiByte.find(slashRslashN, start_pos)) != std::string::npos) {
|
||||
multiByte.replace(start_pos, slashRslashN.length(), slashN);
|
||||
start_pos += slashN.length();
|
||||
}
|
||||
|
||||
m_file << multiByte;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,6 +53,8 @@ namespace Microsoft.AspNetCore.Server.IIS.FunctionalTests
|
|||
var contents = Helpers.ReadAllTextFromFile(Helpers.GetExpectedLogName(deploymentResult, _logFolderPath), Logger);
|
||||
|
||||
Assert.Contains("TEST MESSAGE", contents);
|
||||
Assert.DoesNotContain("\r\n\r\n", contents);
|
||||
Assert.Contains("\r\n", contents);
|
||||
}
|
||||
|
||||
// Move to separate file
|
||||
|
|
|
|||
Loading…
Reference in New Issue