@@ -96,6 +96,14 @@ public FilesystemHelpers(IShellPage associatedInstance, CancellationToken cancel
9696 var progress = new Progress < FileSystemProgress > ( ) ;
9797 progress . ProgressChanged += ( s , e ) => returnStatus = returnStatus < ReturnResult . Failed ? e . Status ! . Value . ToStatus ( ) : returnStatus ;
9898
99+ if ( ! IsValidForFilename ( source . Name ) )
100+ {
101+ await DialogDisplayHelper . ShowDialogAsync (
102+ "ErrorDialogThisActionCannotBeDone" . GetLocalizedResource ( ) ,
103+ "ErrorDialogNameNotAllowed" . GetLocalizedResource ( ) ) ;
104+ return ( ReturnResult . Failed , null ) ;
105+ }
106+
99107 var result = await filesystemOperations . CreateAsync ( source , progress , cancellationToken ) ;
100108
101109 if ( registerHistory && ! string . IsNullOrWhiteSpace ( source . Path ) )
@@ -538,6 +546,14 @@ public async Task<ReturnResult> RenameAsync(IStorageItemWithPath source, string
538546 var progress = new Progress < FileSystemProgress > ( ) ;
539547 progress . ProgressChanged += ( s , e ) => returnStatus = returnStatus < ReturnResult . Failed ? e . Status ! . Value . ToStatus ( ) : returnStatus ;
540548
549+ if ( ! IsValidForFilename ( newName ) )
550+ {
551+ await DialogDisplayHelper . ShowDialogAsync (
552+ "ErrorDialogThisActionCannotBeDone" . GetLocalizedResource ( ) ,
553+ "ErrorDialogNameNotAllowed" . GetLocalizedResource ( ) ) ;
554+ return ReturnResult . Failed ;
555+ }
556+
541557 IStorageHistory history = null ;
542558
543559 switch ( source . ItemType )
@@ -632,6 +648,9 @@ public async Task<ReturnResult> RecycleItemsFromClipboard(DataPackageView packag
632648
633649 #endregion IFilesystemHelpers
634650
651+ private static bool IsValidForFilename ( string name )
652+ => ! string . IsNullOrWhiteSpace ( name ) && ! ContainsRestrictedCharacters ( name ) && ! ContainsRestrictedFileName ( name ) ;
653+
635654 private static async Task < ( List < FileNameConflictResolveOptionType > collisions , bool cancelOperation , IEnumerable < IFileSystemDialogConflictItemViewModel > ) > GetCollision ( FilesystemOperationType operationType , IEnumerable < IStorageItemWithPath > source , IEnumerable < string > destination , bool forceDialog )
636655 {
637656 var incomingItems = new List < BaseFileSystemDialogItemViewModel > ( ) ;
0 commit comments