mirror of
https://github.com/adamhathcock/sharpcompress.git
synced 2026-02-03 21:23:38 +00:00
[PR #1066] [CLOSED] Fix ArjFactory.IsArchive throwing on non-archive files #1490
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/adamhathcock/sharpcompress/pull/1066
Author: @Copilot
Created: 12/8/2025
Status: ❌ Closed
Base:
master← Head:copilot/fix-archivefactory-issue📝 Commits (3)
3752462Initial planbfa0e4aFix ArjFactory.IsArchive to not throw on non-archive filese95e996Remove unused variable from test📊 Changes
2 files changed (+37 additions, -3 deletions)
View changed files
📝
src/SharpCompress/Factories/ArjFactory.cs(+10 -3)📝
tests/SharpCompress.Test/ArchiveTests.cs(+27 -0)📄 Description
Fix ArchiveFactory.IsArchive Regression for ARJ Files
Changes
ArjFactory.IsArchivelogic in try-catch block to handleInvalidDataExceptionArchiveFactory.IsArchivewith non-archive and valid archive filesSummary
Fixed regression in version 0.42.0 where
ArchiveFactory.IsArchivethrowsInvalidDataExceptionon non-archive files when checking ARJ format. The fix wraps theArjMainHeader.Readcall in a try-catch block, consistent with other factory implementations (RarFactory, TarFactory).Root Cause
The
ArjMainHeader.Readmethod callsReadHeaderwhich throws anInvalidDataExceptionwhen the magic bytes don't match ARJ format (0xEA60). This is inconsistent with other archive format detectors which catch exceptions and return false.Testing
Resolves the issue where calling
ArchiveFactory.IsArchiveon simple non-archive files throwsInvalidDataException.Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.