Run Windows games on Apple Silicon — free, open source, with an open compatibility database that tells you what actually works.
Swift apple-silicond3dmetaldxmtdxvkfexgame-porting-toolkitgamingmac-gamingmacosmetalmoltenvksteamswiftuivkd3d-protonwhisky-alternativewindows-gameswinewine-wrapper
fix: reject bottle names Windows paths can't represent (#12)
Gauthier Piarrette210ff87b4a84
diff --git a/Sources/HighballApp/HighballApp.swift b/Sources/HighballApp/HighballApp.swiftindex a78fe34..290d68b 100644--- a/Sources/HighballApp/HighballApp.swift+++ b/Sources/HighballApp/HighballApp.swift@@ -185,6 +185,9 @@ struct CreateBottleSheet: View {VStack(alignment: .leading, spacing: 14) {Text(L("New bottle")).font(.title2.bold())TextField(L("Name"), text: $name).textFieldStyle(.roundedBorder).frame(width: 260)+ if let problem = nameProblem, !name.trimmingCharacters(in: .whitespaces).isEmpty {+ Text(L(problem)).font(.caption).foregroundStyle(.orange).frame(maxWidth: 380, alignment: .leading)+ }Toggle(L("Install Steam in it (recommended)"), isOn: $installSteam)Text(L("A bottle is an isolated Windows environment. First boot takes about 90 seconds; the Steam install adds a download and a slow one-time client update.")).font(.callout).foregroundStyle(.secondary).frame(maxWidth: 380, alignment: .leading)@@ -196,11 +199,13 @@ struct CreateBottleSheet: View {state.createBottle(name: name, recipeID: installSteam ? "steam" : nil)}.keyboardShortcut(.defaultAction)- .disabled(name.trimmingCharacters(in: .whitespaces).isEmpty)+ .disabled(nameProblem != nil)}}.padding(24)}++ private var nameProblem: String? { BottleStore.nameProblem(name) }}struct LogSheet: View {diff --git a/Sources/HighballApp/L10n.swift b/Sources/HighballApp/L10n.swiftindex 1acda47..185313c 100644--- a/Sources/HighballApp/L10n.swift+++ b/Sources/HighballApp/L10n.swift@@ -20,6 +20,13 @@ enum L10n {"Delete": "Supprimer","Cancel": "Annuler","Something went wrong": "Un problème est survenu",+ #"A bottle name can't contain \ / : * ? " < > | — Windows paths forbid them, which would break the bottle."#:+ #"Un nom de bouteille ne peut pas contenir \ / : * ? " < > | — Windows les interdit dans les chemins, ce qui casserait la bouteille."#,+ "The bottle name is empty.": "Le nom de la bouteille est vide.",+ "The bottle name contains control characters.": "Le nom de la bouteille contient des caractères de contrôle.",+ "A bottle name can't start with a dot.": "Un nom de bouteille ne peut pas commencer par un point.",+ "A bottle name can't end with a dot.": "Un nom de bouteille ne peut pas se terminer par un point.",+ "The bottle name is too long (64 characters max).": "Le nom de la bouteille est trop long (64 caractères max).",// Bottle view"Programs": "Programmes",diff --git a/Sources/HighballKit/BottleStore.swift b/Sources/HighballKit/BottleStore.swiftindex fb5ea0f..572cae3 100644--- a/Sources/HighballKit/BottleStore.swift+++ b/Sources/HighballKit/BottleStore.swift@@ -15,8 +15,29 @@ public struct BottleStore: Sendable {try Bottle.load(paths.bottle(name))}+ /// Returns a human-readable problem with a bottle name, or nil if it is usable.+ /// The bottle directory becomes part of the Wine prefix's Windows-side path (Z:\…\bottles\<name>\),+ /// so characters Windows forbids in paths break prefix initialization outright:+ /// wineboot exits 53 with "could not load kernel32.dll, status c0000135" (issue #12).+ public static func nameProblem(_ name: String) -> String? {+ let trimmed = name.trimmingCharacters(in: .whitespaces)+ if trimmed.isEmpty { return "The bottle name is empty." }+ if trimmed.contains(where: { #"\/:*?"<>|"#.contains($0) }) {+ return #"A bottle name can't contain \ / : * ? " < > | — Windows paths forbid them, which would break the bottle."#+ }+ if trimmed.unicodeScalars.contains(where: { CharacterSet.controlCharacters.contains($0) }) {+ return "The bottle name contains control characters."+ }+ if trimmed.hasPrefix(".") { return "A bottle name can't start with a dot." }+ if trimmed.hasSuffix(".") { return "A bottle name can't end with a dot." }+ if trimmed.count > 64 { return "The bottle name is too long (64 characters max)." }+ return nil+ }+/// Creates the directory + gin.json, then runs `wineboot -u` to populate the prefix.- public func create(name: String, engine: InstalledEngine, renderer: Renderer = .dxmt, windowsVersion: WindowsVersion = .win10) async throws -> Bottle {+ public func create(name rawName: String, engine: InstalledEngine, renderer: Renderer = .dxmt, windowsVersion: WindowsVersion = .win10) async throws -> Bottle {+ let name = rawName.trimmingCharacters(in: .whitespaces)+ if let problem = Self.nameProblem(name) { throw HighballError.invalid(problem) }try paths.ensure()let url = paths.bottle(name)guard !FileManager.default.fileExists(atPath: url.path) else { throw HighballError.invalid("bottle '\(name)' already exists") }