diff options
author | Damiano Galassi <[email protected]> | 2017-11-11 08:39:00 +0100 |
---|---|---|
committer | Damiano Galassi <[email protected]> | 2017-11-11 08:39:00 +0100 |
commit | 501055d74f3ee8278d8e03b96e24007876b4652d (patch) | |
tree | f1b579f85b598dc7d7f90f62258e005424ba1af2 /macosx | |
parent | 2a5df5af77d559f66355c984a56a7932260b0ceb (diff) |
MacGui: do not allow the path separator "/" character to be inserted in the output file name.
Diffstat (limited to 'macosx')
-rw-r--r-- | macosx/English.lproj/MainWindow.xib | 6 | ||||
-rw-r--r-- | macosx/HBController.m | 16 | ||||
-rw-r--r-- | macosx/HBJob.m | 19 |
3 files changed, 34 insertions, 7 deletions
diff --git a/macosx/English.lproj/MainWindow.xib b/macosx/English.lproj/MainWindow.xib index 56715f1f1..52a7e2093 100644 --- a/macosx/English.lproj/MainWindow.xib +++ b/macosx/English.lproj/MainWindow.xib @@ -235,7 +235,11 @@ <string key="NSValueTransformerName">NSIsNotNil</string> </dictionary> </binding> - <binding destination="-2" name="value" keyPath="self.job.outputFileName" id="NAL-fw-AF5"/> + <binding destination="-2" name="value" keyPath="self.job.outputFileName" id="SgW-Bn-bwW"> + <dictionary key="options"> + <bool key="NSValidatesImmediately" value="YES"/> + </dictionary> + </binding> </connections> </textField> <textField hidden="YES" toolTip="First second to encode." verticalHuggingPriority="750" misplaced="YES" allowsCharacterPickerTouchBarItem="YES" id="5491"> diff --git a/macosx/HBController.m b/macosx/HBController.m index 83dcc9572..5c255789b 100644 --- a/macosx/HBController.m +++ b/macosx/HBController.m @@ -1117,9 +1117,11 @@ */ - (IBAction)addToQueue:(id)sender { - [self.window HB_endEditing]; - [self runDestinationAlerts:self.job - didEndSelector:@selector(overwriteAddToQueueAlertDone:returnCode:contextInfo:)]; + if ([self.window HB_endEditing]) + { + [self runDestinationAlerts:self.job + didEndSelector:@selector(overwriteAddToQueueAlertDone:returnCode:contextInfo:)]; + } } /** @@ -1166,9 +1168,11 @@ } else { - [self.window HB_endEditing]; - [self runDestinationAlerts:self.job - didEndSelector:@selector(overWriteAlertDone:returnCode:contextInfo:)]; + if ([self.window HB_endEditing]) + { + [self runDestinationAlerts:self.job + didEndSelector:@selector(overWriteAlertDone:returnCode:contextInfo:)]; + } } } diff --git a/macosx/HBJob.m b/macosx/HBJob.m index 8c672445e..d90d95be0 100644 --- a/macosx/HBJob.m +++ b/macosx/HBJob.m @@ -166,6 +166,25 @@ NSString *HBChaptersChangedNotification = @"HBChaptersChangedNotification"; _outputFileName = [outputFileName copy]; } +- (BOOL)validateOutputFileName:(id *)ioValue error:(NSError * __autoreleasing *)outError +{ + BOOL retval = YES; + + if (nil != *ioValue) + { + NSString *value = *ioValue; + + if ([value rangeOfString:@"/"].location != NSNotFound) + { + *outError = [NSError errorWithDomain:@"HBError" code:0 userInfo:@{NSLocalizedDescriptionKey: NSLocalizedString(@"Invalid name", nil), + NSLocalizedRecoverySuggestionErrorKey: NSLocalizedString(@"The file name can't contain the / character.", nil)}]; + return NO; + } + } + + return retval; +} + - (NSURL *)completeOutputURL { return [self.outputURL URLByAppendingPathComponent:self.outputFileName]; |