Skip to content

Commit

Permalink
[hal] Fix RobotController.getComments() mishandling quotes inside the…
Browse files Browse the repository at this point in the history
… 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.
  • Loading branch information
rzblue authored Mar 20, 2023
1 parent e7a7eb2 commit b510c17
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions hal/src/main/native/athena/HAL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit b510c17

Please sign in to comment.