[hal] Fix RobotController.getComments() mishandling quotes inside the comments string (#5197)

Previously, the comment would end at any quote, escaped or unescaped. This allows UnescapeCString to handle the unescaping of quotes and properly end the string.
This commit is contained in:
Ryan Blue
2023-03-20 16:50:25 -04:00
committed by GitHub
parent e7a7eb2e93
commit b510c17ef6

View File

@@ -316,11 +316,8 @@ void InitializeRoboRioComments(void) {
return;
}
start += searchString.size();
size_t end = fileContents.find("\"", start);
if (end == std::string_view::npos) {
end = fileContents.size();
}
std::string_view escapedComments = wpi::slice(fileContents, start, end);
std::string_view escapedComments =
wpi::slice(fileContents, start, fileContents.size());
wpi::SmallString<64> buf;
auto [unescapedComments, rem] = wpi::UnescapeCString(escapedComments, buf);
unescapedComments.copy(roboRioCommentsString,