From daed6eee825e3ff9e6429b96c03f49a4fbde569f Mon Sep 17 00:00:00 2001 From: Dal Rupnik Date: Wed, 20 May 2026 10:36:49 +0200 Subject: [PATCH] fix: parse CRLF stdout from guest agent in GuestDropParseTests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit split(whereSeparator: { $0 == "\n" || $0 == "\r" }) never matches CRLF because Swift treats "\r\n" as a single Character (grapheme cluster U+000D, U+000A), so the closure — which compares against the single-codepoint characters "\n" and "\r" — fires for neither. With CRLF input the entire stdout becomes one "line" that doesn't have the tartdrop-dest= prefix, and the parser returns nil. Switch to String.enumerateLines, which handles LF, CR, and CRLF. --- Sources/tart/GuestDropSynthesis.swift | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Sources/tart/GuestDropSynthesis.swift b/Sources/tart/GuestDropSynthesis.swift index c29ca76..83dd83a 100644 --- a/Sources/tart/GuestDropSynthesis.swift +++ b/Sources/tart/GuestDropSynthesis.swift @@ -239,8 +239,10 @@ enum GuestDropSynthesis { /// match, and takes the *last* such line so a trailing real value wins. /// Returns nil when no non-empty value is present. Pure — unit-tested. static func parseDestinationFolder(stdout: String) -> String? { + // enumerateLines handles LF, CR, and CRLF — split(whereSeparator:) misses + // CRLF because Swift treats "\r\n" as a single Character. var folderName: String? - for line in stdout.split(whereSeparator: { $0 == "\n" || $0 == "\r" }) { + stdout.enumerateLines { line, _ in if line.hasPrefix("tartdrop-dest=") { folderName = String(line.dropFirst("tartdrop-dest=".count)) }