Skip to content

Commit

Permalink
config(qemu): cleanup commas from names
Browse files Browse the repository at this point in the history
Fixes #5332
  • Loading branch information
osy committed May 29, 2023
1 parent ec041e6 commit 08f9a6b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
9 changes: 8 additions & 1 deletion Configuration/UTMQemuConfiguration+Arguments.swift
Original file line number Diff line number Diff line change
Expand Up @@ -852,9 +852,16 @@ import Foundation
}
}

private func cleanupName(_ name: String) -> String {
let allowedCharacterSet = CharacterSet.alphanumerics.union(.whitespaces)
let filteredString = name.components(separatedBy: allowedCharacterSet.inverted)
.joined(separator: "")
return filteredString
}

@QEMUArgumentBuilder private var miscArguments: [QEMUArgument] {
f("-name")
f(information.name)
f(cleanupName(information.name))
if qemu.isDisposable {
f("-snapshot")
}
Expand Down
2 changes: 1 addition & 1 deletion Managers/UTMVirtualMachine.m
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ + (NSString *)virtualMachineName:(NSURL *)url {
}

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

0 comments on commit 08f9a6b

Please sign in to comment.