@@ -32,7 +32,7 @@ public interface IStorageService
3232
3333 string GetHtmlTemplate ( string template ) ;
3434
35- Task < IEnumerable < AssetItem > > Find ( Func < AssetItem , bool > predicate , Pager pager , string path = "" ) ;
35+ Task < IEnumerable < AssetItem > > Find ( Func < AssetItem , bool > predicate , Pager pager , string path = "" , bool sanitize = false ) ;
3636
3737 Task Reset ( ) ;
3838 }
@@ -254,7 +254,7 @@ public async Task<AssetItem> UploadFromWeb(Uri requestUri, string root, string p
254254 }
255255 }
256256
257- public async Task < IEnumerable < AssetItem > > Find ( Func < AssetItem , bool > predicate , Pager pager , string path = "" )
257+ public async Task < IEnumerable < AssetItem > > Find ( Func < AssetItem , bool > predicate , Pager pager , string path = "" , bool sanitize = false )
258258 {
259259 var skip = pager . CurrentPage * pager . ItemsPerPage - pager . ItemsPerPage ;
260260 var files = GetAssets ( path ) ;
@@ -267,6 +267,14 @@ public async Task<IEnumerable<AssetItem>> Find(Func<AssetItem, bool> predicate,
267267
268268 var page = items . Skip ( skip ) . Take ( pager . ItemsPerPage ) . ToList ( ) ;
269269
270+ if ( sanitize )
271+ {
272+ foreach ( var p in page )
273+ {
274+ p . Path = "" ;
275+ }
276+ }
277+
270278 return await Task . FromResult ( page ) ;
271279 }
272280
@@ -331,6 +339,8 @@ public async Task Reset()
331339
332340 void VerifyPath ( string path )
333341 {
342+ path = path . SanitizePath ( ) ;
343+
334344 if ( ! string . IsNullOrEmpty ( path ) )
335345 {
336346 var dir = Path . Combine ( Location , path ) ;
@@ -373,7 +383,7 @@ string GetFileName(string fileName)
373383 Random rnd = new Random ( ) ;
374384 fileName = fileName . Replace ( "mceclip0" , rnd . Next ( 100000 , 999999 ) . ToString ( ) ) ;
375385 }
376- return fileName ;
386+ return fileName . SanitizeFileName ( ) ;
377387 }
378388
379389 string GetUrl ( string path , string root )
@@ -444,7 +454,7 @@ string TitleFromUri(Uri uri)
444454
445455 title = title . Replace ( " " , "-" ) ;
446456
447- return title . Replace ( "/" , "" ) ;
457+ return title . Replace ( "/" , "" ) . SanitizeFileName ( ) ;
448458 }
449459
450460 List < AssetItem > MapFilesToAssets ( IList < string > assets )
0 commit comments