@@ -1364,6 +1364,74 @@ describe('Parse.File testing', () => {
13641364 ) ;
13651365 } ) ;
13661366
1367+ it ( 'works with a period in the file name' , async ( ) => {
1368+ await reconfigureServer ( {
1369+ fileUpload : {
1370+ enableForPublic : true ,
1371+ fileExtensions : [ '^[^hH][^tT][^mM][^lL]?$' ] ,
1372+ } ,
1373+ } ) ;
1374+ const headers = {
1375+ 'X-Parse-Application-Id' : 'test' ,
1376+ 'X-Parse-REST-API-Key' : 'rest' ,
1377+ } ;
1378+
1379+ const values = [ 'file.png.html' , 'file.txt.png.html' , 'file.png.txt.html' ] ;
1380+
1381+ for ( const value of values ) {
1382+ await expectAsync (
1383+ request ( {
1384+ method : 'POST' ,
1385+ headers : headers ,
1386+ url : `http://localhost:8378/1/files/${ value } ` ,
1387+ body : '<html></html>\n' ,
1388+ } ) . catch ( e => {
1389+ throw new Error ( e . data . error ) ;
1390+ } )
1391+ ) . toBeRejectedWith (
1392+ new Parse . Error ( Parse . Error . FILE_SAVE_ERROR , `File upload of extension html is disabled.` )
1393+ ) ;
1394+ }
1395+ } ) ;
1396+
1397+ it ( 'works to stop invalid filenames' , async ( ) => {
1398+ await reconfigureServer ( {
1399+ fileUpload : {
1400+ enableForPublic : true ,
1401+ fileExtensions : [ '^[^hH][^tT][^mM][^lL]?$' ] ,
1402+ } ,
1403+ } ) ;
1404+ const headers = {
1405+ 'X-Parse-Application-Id' : 'test' ,
1406+ 'X-Parse-REST-API-Key' : 'rest' ,
1407+ } ;
1408+
1409+ const values = [
1410+ '!invalid.png' ,
1411+ '.png' ,
1412+ '.html' ,
1413+ ' .html' ,
1414+ '.png.html' ,
1415+ '~invalid.png' ,
1416+ '-invalid.png' ,
1417+ ] ;
1418+
1419+ for ( const value of values ) {
1420+ await expectAsync (
1421+ request ( {
1422+ method : 'POST' ,
1423+ headers : headers ,
1424+ url : `http://localhost:8378/1/files/${ value } ` ,
1425+ body : '<html></html>\n' ,
1426+ } ) . catch ( e => {
1427+ throw new Error ( e . data . error ) ;
1428+ } )
1429+ ) . toBeRejectedWith (
1430+ new Parse . Error ( Parse . Error . INVALID_FILE_NAME , `Filename contains invalid characters.` )
1431+ ) ;
1432+ }
1433+ } ) ;
1434+
13671435 it ( 'works with array' , async ( ) => {
13681436 await reconfigureServer ( {
13691437 fileUpload : {
0 commit comments