From b510c17ef6b3d2b8f3a9b1c62ed23e10a4ba6f24 Mon Sep 17 00:00:00 2001 From: Ryan Blue Date: Mon, 20 Mar 2023 16:50:25 -0400 Subject: [PATCH] [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. --- hal/src/main/native/athena/HAL.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/hal/src/main/native/athena/HAL.cpp b/hal/src/main/native/athena/HAL.cpp index eda229af95..1b6ef41598 100644 --- a/hal/src/main/native/athena/HAL.cpp +++ b/hal/src/main/native/athena/HAL.cpp @@ -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,