From 49dfdd87e13867711e8e1c53102e05b4b721aef3 Mon Sep 17 00:00:00 2001 From: Thiago Gonzaga Date: Sat, 25 Jul 2026 16:17:21 -0300 Subject: [PATCH] Split mount directives on the first equals sign Parser.mount split each comma-separated directive with maxSplits: 2, which yields three components when the value itself contains an equals sign. The parser then requires exactly two components, so any mount whose source or destination path contains "=" failed with "invalid directive format missing value". Equals signs are legal in POSIX path names. Splitting on the first equals sign keeps the remainder as the value. Fixes #2012 --- .../ContainerAPIService/Client/Parser.swift | 2 +- .../ContainerAPIClientTests/ParserTest.swift | 20 +++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/Sources/Services/ContainerAPIService/Client/Parser.swift b/Sources/Services/ContainerAPIService/Client/Parser.swift index ef209df5c..0dbf38972 100644 --- a/Sources/Services/ContainerAPIService/Client/Parser.swift +++ b/Sources/Services/ContainerAPIService/Client/Parser.swift @@ -368,7 +368,7 @@ public struct Parser { } var directives = defaultDirectives for part in parts { - let keyVal = part.split(separator: "=", maxSplits: 2) + let keyVal = part.split(separator: "=", maxSplits: 1) var key = String(keyVal[0]) var skipValue = false switch key { diff --git a/Tests/ContainerAPIClientTests/ParserTest.swift b/Tests/ContainerAPIClientTests/ParserTest.swift index 0dcc6f7cf..4ff6df4c6 100644 --- a/Tests/ContainerAPIClientTests/ParserTest.swift +++ b/Tests/ContainerAPIClientTests/ParserTest.swift @@ -457,6 +457,26 @@ struct ParserTest { } } + @Test + func testMountBindSourceContainingEquals() throws { + let tempDir = FileManager.default.temporaryDirectory.appendingPathComponent("test-bind-eq-\(UUID().uuidString)=v1") + try FileManager.default.createDirectory(at: tempDir, withIntermediateDirectories: true) + defer { + try? FileManager.default.removeItem(at: tempDir) + } + + let result = try Parser.mount("type=bind,src=\(tempDir.path),dst=/foo") + + switch result { + case .filesystem(let fs): + #expect(fs.source == tempDir.path) + #expect(fs.destination == "/foo") + #expect(!fs.isVolume) + case .volume: + #expect(Bool(false), "Expected filesystem mount, got volume") + } + } + @Test func testMountVolumeValidName() throws { let result = try Parser.mount("type=volume,src=myvolume,dst=/data")