1- using BlogEngine . Core . Data . Contracts ;
1+ using BlogEngine . Core ;
2+ using BlogEngine . Core . Data . Contracts ;
23using BlogEngine . Core . FileSystem ;
34using BlogEngine . Core . Providers ;
45using System ;
@@ -24,6 +25,11 @@ public IEnumerable<FileInstance> Get(int take = 10, int skip = 0, string path =
2425 [ HttpPut ]
2526 public HttpResponseMessage ProcessChecked ( [ FromBody ] List < FileInstance > items )
2627 {
28+ if ( ! Security . IsAdministrator )
29+ {
30+ throw new UnauthorizedAccessException ( ) ;
31+ }
32+
2733 if ( items == null || items . Count == 0 )
2834 throw new HttpResponseException ( HttpStatusCode . ExpectationFailed ) ;
2935
@@ -36,10 +42,10 @@ public HttpResponseMessage ProcessChecked([FromBody]List<FileInstance> items)
3642 if ( item . IsChecked )
3743 {
3844 if ( item . FileType == FileType . File || item . FileType == FileType . Image )
39- BlogService . DeleteFile ( item . FullPath ) ;
45+ BlogService . DeleteFile ( Extensions . SanitizePath ( item . FullPath ) ) ;
4046
4147 if ( item . FileType == FileType . Directory )
42- BlogService . DeleteDirectory ( item . FullPath ) ;
48+ BlogService . DeleteDirectory ( Extensions . SanitizePath ( item . FullPath ) ) ;
4349 }
4450 }
4551 }
@@ -49,7 +55,11 @@ public HttpResponseMessage ProcessChecked([FromBody]List<FileInstance> items)
4955 [ HttpPut ]
5056 public HttpResponseMessage AddFolder ( FileInstance folder )
5157 {
52- BlogService . CreateDirectory ( folder . FullPath + "/" + folder . Name ) ;
58+ if ( ! Security . IsAdministrator )
59+ {
60+ throw new UnauthorizedAccessException ( ) ;
61+ }
62+ BlogService . CreateDirectory ( Extensions . SanitizePath ( folder . FullPath ) + "/" + Extensions . SanitizePath ( folder . Name ) ) ;
5363 return Request . CreateResponse ( HttpStatusCode . OK ) ;
5464 }
5565
0 commit comments