Skip to content

Commit

Permalink
vm: allow creation with illegal path characters in name
Browse files Browse the repository at this point in the history
Fixes #4385
  • Loading branch information
osy committed Sep 10, 2022
1 parent 39b8c17 commit 64ba7f8
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 2 additions & 0 deletions Managers/UTMVirtualMachine.m
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@ + (NSString *)virtualMachineName:(NSURL *)url {
}

+ (NSURL *)virtualMachinePath:(NSString *)name inParentURL:(NSURL *)parent {
NSCharacterSet *illegalFileNameCharacters = [NSCharacterSet characterSetWithCharactersInString:@"/:\\?%*|\"<>"];
name = [[name componentsSeparatedByCharactersInSet:illegalFileNameCharacters] componentsJoinedByString:@"-"];
return [[parent URLByAppendingPathComponent:name] URLByAppendingPathExtension:kUTMBundleExtension];
}

Expand Down
2 changes: 1 addition & 1 deletion Managers/UTMVirtualMachine.swift
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ extension UTMVirtualMachine: ObservableObject {
func saveUTM() async throws {
let fileManager = FileManager.default
let existingPath = path
let newPath = existingPath.deletingLastPathComponent().appendingPathComponent(config.name).appendingPathExtension("utm")
let newPath = UTMVirtualMachine.virtualMachinePath(config.name, inParentURL: existingPath.deletingLastPathComponent())
do {
try await config.save(to: existingPath)
try await updateRegistryFromConfig()
Expand Down

0 comments on commit 64ba7f8

Please sign in to comment.