SharpCompressArchiveHandler: throw fewer exceptions

This commit is contained in:
zeromus 2020-02-09 23:27:09 -05:00
parent e4f94fab8e
commit 4617476bcd
2 changed files with 13 additions and 2 deletions

View File

@ -25,12 +25,22 @@ namespace BizHawk.Client.Common
{
_archive?.Dispose();
_archive = null;
}
}
/// <summary>
/// whitelist extensions, to avoid thrown exceptions
/// </summary>
public string[] ArchiveExtensions = { ".zip", ".gz", ".gzip", ".tar", ".rar", ".7z" };
public bool CheckSignature(string fileName, out int offset, out bool isExecutable)
{
offset = 0;
isExecutable = false;
var pathExt = Path.GetExtension(fileName).ToLower();
if (!ArchiveExtensions.Contains(pathExt))
return false;
try
{
using (var arcTest = ArchiveFactory.Open(fileName))

View File

@ -440,7 +440,8 @@ namespace BizHawk.Common
int offset;
bool isExecutable;
if (NonArchiveExtensions.Any(ext => Path.GetExtension(path).ToLower() == ext.ToLower()))
var pathExt = Path.GetExtension(path).ToLower();
if (NonArchiveExtensions.Contains(pathExt))
{
return;
}