Skip to content

Commit

Permalink
Better Zip Extraction pt.2
Browse files Browse the repository at this point in the history
  • Loading branch information
harryjph committed Jul 14, 2019
1 parent 9800d63 commit 57bcc75
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions QBundle/frmDownloadManager.vb
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,21 @@ Public Class frmDownloadManager
Try
Dim filename As String = QGlobal.AppDir & Path.GetFileName(Url)
Dim target As String = QGlobal.AppDir
Using archive As ZipArchive = ZipFile.OpenRead(filename)
For Each entry As ZipArchiveEntry In archive.Entries
If Not entry.FullName.EndsWith("/") Then
Dim destFileName = Path.Combine(target, entry.FullName)
Dim fullDestDirPath = Path.GetFullPath(target + Path.DirectorySeparatorChar)
If Not destFileName.StartsWith(fullDestDirPath) Then
Throw New Exception("Entry is outside of target dir: " + destFileName)
End If
Try
My.Computer.FileSystem.DeleteFile(destFileName)
Catch ex As FileNotFoundException
End Try
End If
Next
End Using
ZipFile.ExtractToDirectory(filename, target)
AllOk = True
Catch ex As Exception
Expand Down

0 comments on commit 57bcc75

Please sign in to comment.