@@ -590,32 +590,41 @@ public ActionResult<ContentTypeImportModel> Upload(List<IFormFile> file)
590
590
591
591
var root = _hostingEnvironment . MapPathContentRoot ( Constants . SystemDirectories . TempFileUploads ) ;
592
592
var tempPath = Path . Combine ( root , fileName ) ;
593
-
594
- using ( var stream = System . IO . File . Create ( tempPath ) )
595
- {
596
- formFile . CopyToAsync ( stream ) . GetAwaiter ( ) . GetResult ( ) ;
597
- }
598
-
599
- if ( ext . InvariantEquals ( "udt" ) )
593
+ if ( Path . GetFullPath ( tempPath ) . StartsWith ( Path . GetFullPath ( root ) ) )
600
594
{
601
- model . TempFileName = Path . Combine ( root , fileName ) ;
595
+ using ( var stream = System . IO . File . Create ( tempPath ) )
596
+ {
597
+ formFile . CopyToAsync ( stream ) . GetAwaiter ( ) . GetResult ( ) ;
598
+ }
602
599
603
- var xd = new XmlDocument
600
+ if ( ext . InvariantEquals ( "udt" ) )
604
601
{
605
- XmlResolver = null
606
- } ;
607
- xd . Load ( model . TempFileName ) ;
602
+ model . TempFileName = Path . Combine ( root , fileName ) ;
608
603
609
- model . Alias = xd . DocumentElement ? . SelectSingleNode ( "//DocumentType/Info/Alias" ) ? . FirstChild . Value ;
610
- model . Name = xd . DocumentElement ? . SelectSingleNode ( "//DocumentType/Info/Name" ) ? . FirstChild . Value ;
611
- }
612
- else
604
+ var xd = new XmlDocument
605
+ {
606
+ XmlResolver = null
607
+ } ;
608
+ xd . Load ( model . TempFileName ) ;
609
+
610
+ model . Alias = xd . DocumentElement ? . SelectSingleNode ( "//DocumentType/Info/Alias" ) ? . FirstChild . Value ;
611
+ model . Name = xd . DocumentElement ? . SelectSingleNode ( "//DocumentType/Info/Name" ) ? . FirstChild . Value ;
612
+ }
613
+ else
614
+ {
615
+ model . Notifications . Add ( new BackOfficeNotification (
616
+ _localizedTextService . Localize ( "speechBubbles" , "operationFailedHeader" ) ,
617
+ _localizedTextService . Localize ( "media" , "disallowedFileType" ) ,
618
+ NotificationStyle . Warning ) ) ;
619
+ }
620
+ } else
613
621
{
614
622
model . Notifications . Add ( new BackOfficeNotification (
615
- _localizedTextService . Localize ( "speechBubbles" , "operationFailedHeader" ) ,
616
- _localizedTextService . Localize ( "media" , "disallowedFileType ") ,
623
+ _localizedTextService . Localize ( "speechBubbles" , "operationFailedHeader" ) ,
624
+ _localizedTextService . Localize ( "media" , "invalidFileName ") ,
617
625
NotificationStyle . Warning ) ) ;
618
626
}
627
+
619
628
}
620
629
621
630
0 commit comments