This repository was archived by the owner on Oct 14, 2024. It is now read-only.
  
  
  
  
    
    
    
      
    
  
  
    
File tree Expand file tree Collapse file tree 2 files changed +12
-0
lines changed 
AjaxControlToolkit/AjaxFileUpload Expand file tree Collapse file tree 2 files changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ public class AjaxFileUploadTests {
1010        string  _tempFolder ; 
1111        const  string  testBody  =  "------WebKitFormBoundaryCqenIHPHe1ZTCr0d\r \n Content-Disposition: form-data; name=\" act-file-data\" ; filename=\" zero.jpg\" \r \n Content-Type: image/jpeg\r \n \r \n \r \n ------WebKitFormBoundaryCqenIHPHe1ZTCr0d--\r \n " ; 
1212        const  string  testQuery  =  "filename=aaa.jpg&fileId=E63F2078-D5C7-66FA-5CAD-02C169149BD5" ; 
13+         const  string  testQueryFilenameInvalidChars  =  "filename=a:a*a.jpg&fileId=E63F2078-D5C7-66FA-5CAD-02C169149BD5" ;  
1314        const  string  testQueryNoExtension  =  "filename=aaa&fileId=E63F2078-D5C7-66FA-5CAD-02C169149BD5" ; 
1415        const  string  testContentType  =  "multipart/form-data; boundary=----WebKitFormBoundaryCqenIHPHe1ZTCr0d" ; 
1516
@@ -88,5 +89,13 @@ public void DoNotUseBufferlessInputStream() {
8889            var  context  =  new  HttpContext ( request ) ; 
8990            Assert . DoesNotThrow ( ( )  =>  AjaxFileUploadHelper . Process ( context ) ) ; 
9091        } 
92+ 
93+         [ Test ] 
94+         public  void  InvalidFilenameChars ( )  { 
95+             var  request  =  new  WorkerRequest ( testBody ,  testQueryFilenameInvalidChars ,  testContentType ) ; 
96+             var  context  =  new  HttpContext ( request ) ; 
97+             AjaxFileUploadHelper . Process ( context ) ; 
98+             Assert . True ( File . Exists ( Path . Combine ( _tempFolder ,  "E63F2078-D5C7-66FA-5CAD-02C169149BD5" ,  "a-a-a.jpg.tmp" ) ) ) ; 
99+         } 
91100    } 
92101} 
Original file line number Diff line number Diff line change @@ -201,6 +201,9 @@ static void CreateTempFilePathFolder(string tmpFilePath) {
201201
202202        private  static   string  GetTempFilePath ( string  fileId ,  string  fileName )  { 
203203            var  tempFolder  =  AjaxFileUpload . GetTempFolder ( fileId ) ; 
204+             foreach  ( var  invalidChar  in  Path . GetInvalidFileNameChars ( ) )  { 
205+                 fileName  =  fileName . Replace ( invalidChar ,  '-' ) ; 
206+             } 
204207            return  Path . Combine ( tempFolder ,  fileName )  +  Constants . UploadTempFileExtension ; 
205208        } 
206209    } 
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments