]> granicus.if.org Git - handbrake/commitdiff
MacGui: do not allow the path separator "/" character to be inserted in the output...
authorDamiano Galassi <damiog@gmail.com>
Sat, 11 Nov 2017 07:39:00 +0000 (08:39 +0100)
committerDamiano Galassi <damiog@gmail.com>
Sat, 11 Nov 2017 07:39:00 +0000 (08:39 +0100)
macosx/English.lproj/MainWindow.xib
macosx/HBController.m
macosx/HBJob.m

index 56715f1f1b1ede67c19ebbae0dae347bdbee40ba..52a7e209365cfaaf79bb9ea7675887b48a150f44 100644 (file)
                                     <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">
index 83dcc9572cb155bcfd15fb2329db95d679662c6b..5c255789b1a54c0736313a0a16fb2e544d8350af 100644 (file)
  */
 - (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:)];
+    }
 }
 
 /**
     }
     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:)];
+        }
     }
 }
 
index 8c672445e3258983d3bf40eb5b8327611d19399b..d90d95be00badc937c3b452ff708b45d40665a32 100644 (file)
@@ -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];