From 515a81537ca76ab157b99247f8fbf23fd244cd74 Mon Sep 17 00:00:00 2001 From: Sebastian Serth Date: Sun, 24 Sep 2023 15:42:26 +0200 Subject: [PATCH] Connection::Buffer: Prevent modification of line breaks in quotes After splitting the messages received into lines, we could still have a line break within quotes. Since we just want to modify terminating line breaks, we change the recognition accordingly. --- lib/runner/connection/buffer.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/runner/connection/buffer.rb b/lib/runner/connection/buffer.rb index 72df996d..d6e15e48 100644 --- a/lib/runner/connection/buffer.rb +++ b/lib/runner/connection/buffer.rb @@ -82,7 +82,8 @@ class Runner::Connection::Buffer @global_buffer = +'' # For our buffering, we identified line breaks with the `\n` and removed those temporarily. # Thus, we now re-add the `\n` at the end of the string and remove the `\r` at the same time. - message = message.gsub(/\r$/, "\n") + # Still, some messages might still contain a `\r\n` within strings (e.g., received from Python for the linter). + message = message.gsub(/\r(?!\n)$/, "\n") @line_buffer.push message end