@@ -96,6 +96,14 @@ public FilesystemHelpers(IShellPage associatedInstance, CancellationToken cancel
96
96
var progress = new Progress < FileSystemProgress > ( ) ;
97
97
progress . ProgressChanged += ( s , e ) => returnStatus = returnStatus < ReturnResult . Failed ? e . Status ! . Value . ToStatus ( ) : returnStatus ;
98
98
99
+ if ( ! IsValidForFilename ( source . Name ) )
100
+ {
101
+ await DialogDisplayHelper . ShowDialogAsync (
102
+ "ErrorDialogThisActionCannotBeDone" . GetLocalizedResource ( ) ,
103
+ "ErrorDialogNameNotAllowed" . GetLocalizedResource ( ) ) ;
104
+ return ( ReturnResult . Failed , null ) ;
105
+ }
106
+
99
107
var result = await filesystemOperations . CreateAsync ( source , progress , cancellationToken ) ;
100
108
101
109
if ( registerHistory && ! string . IsNullOrWhiteSpace ( source . Path ) )
@@ -538,6 +546,14 @@ public async Task<ReturnResult> RenameAsync(IStorageItemWithPath source, string
538
546
var progress = new Progress < FileSystemProgress > ( ) ;
539
547
progress . ProgressChanged += ( s , e ) => returnStatus = returnStatus < ReturnResult . Failed ? e . Status ! . Value . ToStatus ( ) : returnStatus ;
540
548
549
+ if ( ! IsValidForFilename ( newName ) )
550
+ {
551
+ await DialogDisplayHelper . ShowDialogAsync (
552
+ "ErrorDialogThisActionCannotBeDone" . GetLocalizedResource ( ) ,
553
+ "ErrorDialogNameNotAllowed" . GetLocalizedResource ( ) ) ;
554
+ return ReturnResult . Failed ;
555
+ }
556
+
541
557
IStorageHistory history = null ;
542
558
543
559
switch ( source . ItemType )
@@ -632,6 +648,9 @@ public async Task<ReturnResult> RecycleItemsFromClipboard(DataPackageView packag
632
648
633
649
#endregion IFilesystemHelpers
634
650
651
+ private static bool IsValidForFilename ( string name )
652
+ => ! string . IsNullOrWhiteSpace ( name ) && ! ContainsRestrictedCharacters ( name ) && ! ContainsRestrictedFileName ( name ) ;
653
+
635
654
private static async Task < ( List < FileNameConflictResolveOptionType > collisions , bool cancelOperation , IEnumerable < IFileSystemDialogConflictItemViewModel > ) > GetCollision ( FilesystemOperationType operationType , IEnumerable < IStorageItemWithPath > source , IEnumerable < string > destination , bool forceDialog )
636
655
{
637
656
var incomingItems = new List < BaseFileSystemDialogItemViewModel > ( ) ;
0 commit comments