@@ -410,13 +410,14 @@ export abstract class DiscordBaseIndexer {
410410 await fs . ensureDir ( levelDir ) ;
411411
412412 // Download the .dat file
413- const datPath = path . join ( levelDir , datAttachment . filename ) ;
413+ const sanitizedDatName = FileUtils . sanitizeFilename ( datAttachment . filename ) ;
414+ const datPath = path . join ( levelDir , sanitizedDatName ) ;
414415 await this . downloadFile ( datAttachment . url , datPath ) ;
415416
416417 // Create level files array
417418 const files : LevelFile [ ] = [
418419 {
419- filename : datAttachment . filename ,
420+ filename : sanitizedDatName ,
420421 path : datPath ,
421422 size : datAttachment . size ,
422423 type : 'dat' ,
@@ -426,25 +427,27 @@ export abstract class DiscordBaseIndexer {
426427 // Download associated images
427428 for ( const imageAtt of associatedImages ) {
428429 try {
429- const imageName = imageAtt . filename ;
430- logger . info ( `Downloading image: ${ imageName } for level ${ datAttachment . filename } ` ) ;
431- const imagePath = path . join ( levelDir , imageName ) ;
430+ const sanitizedImageName = FileUtils . sanitizeFilename ( imageAtt . filename ) ;
431+ logger . info (
432+ `Downloading image: ${ imageAtt . filename } for level ${ datAttachment . filename } `
433+ ) ;
434+ const imagePath = path . join ( levelDir , sanitizedImageName ) ;
432435 await this . downloadFile ( imageAtt . url , imagePath ) ;
433436
434437 // Determine image type
435438 let imageType : 'thumbnail' | 'image' = 'image' ;
436- if ( imageName . toLowerCase ( ) . includes ( 'thumb' ) ) {
439+ if ( sanitizedImageName . toLowerCase ( ) . includes ( 'thumb' ) ) {
437440 imageType = 'thumbnail' ;
438441 }
439442
440443 files . push ( {
441- filename : imageName ,
444+ filename : sanitizedImageName ,
442445 path : imagePath ,
443446 size : imageAtt . size ,
444447 type : imageType ,
445448 } ) ;
446449
447- logger . info ( `Downloaded image: ${ imageName } (${ imageType } )` ) ;
450+ logger . info ( `Downloaded image: ${ sanitizedImageName } (${ imageType } )` ) ;
448451 } catch ( error ) {
449452 logger . warn ( `Failed to download image ${ imageAtt . filename } :` , error ) ;
450453 }
@@ -569,7 +572,8 @@ export abstract class DiscordBaseIndexer {
569572
570573 // Download ZIP file
571574 logger . info ( `Downloading zip: ${ zipAttachment . filename } ` ) ;
572- const zipPath = path . join ( tempDir , zipAttachment . filename ) ;
575+ const sanitizedZipName = FileUtils . sanitizeFilename ( zipAttachment . filename ) ;
576+ const zipPath = path . join ( tempDir , sanitizedZipName ) ;
573577 await this . downloadFile ( zipAttachment . url , zipPath ) ;
574578
575579 // Extract ZIP
0 commit comments