Skip to content

Commit 24a9263

Browse files
committed
#4 #5
1 parent 131be0e commit 24a9263

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11

22
.DS_Store
3+
# Local configuration file for developers
4+
src/Application/src/RazorPagesTestSample/config.json

src/Application/src/RazorPagesTestSample/Pages/Index.cshtml.cs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,15 @@ public async Task<IActionResult> OnPostAnalyzeMessagesAsync()
9292
return RedirectToPage();
9393
}
9494

95-
public static void WriteToDirectory(ZipArchiveEntry entry, string destDirectory)
96-
{
97-
string destFileName = Path.Combine(destDirectory, entry.FullName);
98-
entry.ExtractToFile(destFileName);
95+
public static void WriteToDirectory(ZipArchiveEntry entry, string destDirectory)
96+
{
97+
string destFileName = Path.GetFullPath(Path.Combine(destDirectory, entry.FullName));
98+
string fullDestDirPath = Path.GetFullPath(destDirectory + Path.DirectorySeparatorChar);
99+
if (!destFileName.StartsWith(fullDestDirPath)) {
100+
throw new System.InvalidOperationException("Entry is outside the target dir: " + destFileName);
99101
}
102+
entry.ExtractToFile(destFileName);
103+
}
104+
100105
}
101106
}

src/Application/tests/RazorPagesTestSample.Tests/RazorPagesTestSample.Tests.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="8.0.3" />
1414
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
1515
<PackageReference Include="Moq" Version="4.20.70" />
16-
<PackageReference Include="Newtonsoft.Json" Version="11.0.2" />
16+
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
1717
<PackageReference Include="System.Diagnostics.TraceSource" Version="4.3.0" />
1818
<PackageReference Include="System.Net.Http" Version="4.3.4" />
1919
<PackageReference Include="xunit" Version="2.7.0" />

0 commit comments

Comments
 (0)