File tree Expand file tree Collapse file tree 1 file changed +4
-3
lines changed
src/Application/src/RazorPagesTestSample/Pages Expand file tree Collapse file tree 1 file changed +4
-3
lines changed Original file line number Diff line number Diff line change @@ -94,12 +94,13 @@ public async Task<IActionResult> OnPostAnalyzeMessagesAsync()
94
94
95
95
public static void WriteToDirectory ( ZipArchiveEntry entry , string destDirectory )
96
96
{
97
- string destFileName = Path . Combine ( destDirectory , entry . FullName ) ;
97
+ string destFileName = Path . GetFullPath ( Path . Combine ( destDirectory , entry . FullName ) ) ;
98
+ string fullDestDirPath = Path . GetFullPath ( destDirectory + Path . DirectorySeparatorChar ) ;
98
99
99
100
// Ensure the destination file is within the destination directory
100
- if ( ! Path . GetFullPath ( destFileName ) . StartsWith ( Path . GetFullPath ( destDirectory ) , StringComparison . Ordinal ) )
101
+ if ( ! destFileName . StartsWith ( fullDestDirPath , StringComparison . Ordinal ) )
101
102
{
102
- throw new InvalidOperationException ( "Entry is trying to write outside of the destination directory." ) ;
103
+ throw new InvalidOperationException ( "Entry is trying to write outside of the destination directory." ) ;
103
104
}
104
105
105
106
entry . ExtractToFile ( destFileName ) ;
You can’t perform that action at this time.
0 commit comments