Uninstall Mac apps with every file they leave behind, and see why each belongs. Free up space, fine-tune macOS, and set up Terminal.
Swift cache-cleanercleanerclideveloper-toolsdisk-cleanupdisk-spaceduplicate-finderhomebrewliquid-glassmac-cleanermacosmacos-appmacos-golden-gatemacos-tahoemacos-tweaksswiftswiftuiterminal-themesuninstalluninstaller
A line of only tabs in launchctl's overrides no longer crashes Peel
Țugui Dragoșbbd9d36bb3de
diff --git a/Packages/PeelCore/Sources/PeelCore/BackgroundItems/Launchctl.swift b/Packages/PeelCore/Sources/PeelCore/BackgroundItems/Launchctl.swiftindex 90a6a523..941b5487 100644--- a/Packages/PeelCore/Sources/PeelCore/BackgroundItems/Launchctl.swift+++ b/Packages/PeelCore/Sources/PeelCore/BackgroundItems/Launchctl.swift@@ -65,9 +65,11 @@ enum Launchctl {}guard overrides != nil else { continue }if trimmed == "}" { break }- // Finds the last arrow after the opening quote, because a label can contain an arrow of its own.+ // Finds the last arrow after the opening quote, because a label can contain an arrow of its own. The+ // quote is checked first: a label can hold a line break, which leaves a line with nothing after the tabs.+ guard trimmed.hasPrefix("\"") else { continue }let afterQuote = trimmed.index(after: trimmed.startIndex)..<trimmed.endIndex- guard trimmed.hasPrefix("\""), let arrow = trimmed.range(of: "\" => ", options: .backwards, range: afterQuote) else { continue }+ guard let arrow = trimmed.range(of: "\" => ", options: .backwards, range: afterQuote) else { continue }let label = String(trimmed[trimmed.index(after: trimmed.startIndex)..<arrow.lowerBound])overrides?[label] = trimmed[arrow.upperBound...].hasPrefix("disabled")}diff --git a/Packages/PeelCore/Tests/PeelCoreTests/LaunchctlTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/LaunchctlTests.swiftindex eea429fc..01c01aae 100644--- a/Packages/PeelCore/Tests/PeelCoreTests/LaunchctlTests.swift+++ b/Packages/PeelCore/Tests/PeelCoreTests/LaunchctlTests.swift@@ -13,6 +13,14 @@ struct LaunchctlTests {#expect(parsed?["com.example.agent"] == false)}+ /// A label can hold a line break, so a line inside the block can hold nothing but tabs.+ @Test func aLineOfOnlyTabsInsideTheBlockDoesNotCrashTheParser() {+ let output = "\tdisabled services = {\n\t\t\"com.example.x\n\t\t\n\" => disabled\n\t\t\"com.example.agent\" => enabled\n\t}"+ let parsed = Launchctl.parseDisabled(output)++ #expect(parsed?["com.example.agent"] == false)+ }+@Test func parsesUserJobList() throws {let output = "PID\tStatus\tLabel\n-\t0\tcom.adguard.mac.adguard.loginhelper\n22251\t0\tapplication.com.example.jotter.22249290.22249296\n"let jobs = try #require(Launchctl.parseList(output))