Commit Graph

3156 Commits

Author SHA1 Message Date
drone1400
fb0cd47bb0 Add tests for long USTAR names split at a directory separator
When an entry name is longer than the 100 byte USTAR name field,
TarHeader splits it into the 155 byte prefix field and the name field
at a directory separator. The existing tests only covered short paths
and long names without any separator.

Add sync and async tests that write a 186 byte path (with '/' and
'\' separators as input) using the USTAR format and read it back.

On Windows these tests fail with InvalidFormatException ("Directory
separator not found!"), which the next commit fixes. They pass on
Linux and macOS.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-30 11:48:10 +02:00
Adam Hathcock
dedbf6ac57 Merge pull request #1481 from adamhathcock/adam/lzma2-invalid-props
Report invalid LZMA2 chunk properties as a data error
2026-10-27 15:32:27 +00:00
Adam Hathcock
c4028139fd Report invalid LZMA2 chunk properties as a data error
An LZMA2 chunk header properties byte of 225 or more cannot occur in
valid data, but it reached Decoder.SetDecoderProperties and surfaced as
InvalidParamException. EncryptedDecoderStream only maps DataErrorException
to CryptographicException, so a wrong 7z password occasionally leaked the
internal codec exception, making
SevenZipWriter_Encrypted_WrongPasswordFails flaky.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-27 15:02:07 +00:00
Adam Hathcock
51c00c62d8 Merge pull request #1480 from wleeaf/empty-compressed-streams
Write a valid compressed stream when no data is written
2026-10-27 13:48:40 +00:00
Adam Hathcock
c6712678d6 Merge pull request #1479 from wleeaf/zip-utf8-name-flag
Set the UTF-8 flag for zip entry names encoded as UTF-8 without a BOM
2026-10-27 13:47:53 +00:00
Wleeaf
aa54f11acc Write a valid compressed stream when no data is written 2026-10-26 20:47:22 +00:00
Wleeaf
ea2986708f Set the UTF-8 flag for zip entry names encoded as UTF-8 without a BOM 2026-10-26 16:48:33 +00:00
Adam Hathcock
b2fade6400 allow pre-release tags 0.51.0-beta2 2026-10-26 16:47:21 +00:00
Adam Hathcock
deaabb5504 Merge pull request #1469 from adamhathcock/dependabot/nuget/build/all-dependencies-232486072c
Bump the all-dependencies group with 5 updates
0.51.0-beta1
2026-10-26 16:35:15 +00:00
Adam Hathcock
f34ac19f22 Merge pull request #1478 from adamhathcock/perf/sevenzip-allocation-fixes
Reduce allocations in 7z encryption and codec lookup
2026-10-26 14:24:50 +00:00
Adam Hathcock
dd6d09c6d2 Reduce allocations in 7z encryption and codec lookup 2026-10-26 13:45:21 +00:00
Adam Hathcock
fa96277b96 Merge pull request #1476 from jaysanati/feature/7z-write-encryption-master
SevenZipWriter: password protection (7zAES) and encrypted headers
2026-10-26 13:17:32 +00:00
Adam Hathcock
2fa1dec513 Merge pull request #1473 from adamhathcock/review/fix-zip64-descriptor-width
Fix ZIP64 streaming data descriptor width parsing
2026-10-26 11:36:16 +00:00
Adam Hathcock
8fa17607d8 Merge pull request #1477 from adamhathcock/perf/xz-async-decoding
Optimize XZ async reads and buffered LZMA2 decoding
2026-10-26 08:27:00 +00:00
Adam Hathcock
0a716d4236 Merge pull request #1475 from jaysanati/fix/7z-encrypted-compression-type
Report the codec, not 7zAES, as an encrypted 7z entry's CompressionType
2026-10-26 08:24:34 +00:00
Adam Hathcock
0c6b575135 Merge remote-tracking branch 'origin/master' into perf/xz-async-decoding 2026-10-26 08:01:44 +00:00
Adam Hathcock
4a07d63f13 Merge pull request #1474 from adamhathcock/fix/xz-bcj-streaming
Fix streaming XZ BCJ decoding and release pooled filter buffers
2026-10-26 08:00:24 +00:00
Jay Sanati
521a33688a Add 7z write encryption (7zAES) and encrypted headers
SevenZipWriterOptions gains Password and EncryptHeader (#1472). With a
password, each folder is written as 7zAES -> LZMA/LZMA2 in the same
layout 7-Zip uses: AES is coder 0 and reads the packed stream, the
codec is coder 1 and reads AES's output. AES properties match 7-Zip's
defaults (NumCyclesPower 19, no salt, random 16-byte IV per folder), so
the key is derived once per archive. EncryptHeader runs the header
through the same chain; an encrypted header is always LZMA-compressed.
Empty files have no stream and stay unencrypted, as in 7-Zip.

- SevenZipAesKey: the 7zAES KDF, moved unchanged from AesDecoderStream
  so the encoder and decoder share it.
- AesEncoderStream: AES-256-CBC, zero-fills the last block on Finish.
- SevenZipAesEncryption: per-archive key and per-folder IV/properties.
- EncryptHeader without a password, or an empty password, throws
  ArgumentException.

Uses only Aes (CBC) and SHA256, available on every target framework and
Native AOT safe. Verified with 7-Zip 26.05 (7z t, 7z x, 7z l -slt) and
WinRAR for LZMA and LZMA2, with and without header encryption.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-24 13:27:20 -07:00
Jay Sanati
a7d3b100a0 Report the codec, not 7zAES, as an encrypted 7z entry's CompressionType
7-Zip writes 7zAES as the first coder of an encrypted folder, in front
of the codec. SevenZipFilePart.GetCompression() looked at the first
coder only, so CompressionType threw InvalidFormatException for every
entry of a 7-Zip-made encrypted archive. Skip the AES filter and report
the first real coder.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-24 13:27:20 -07:00
Jay Sanati
6d51b39230 Report the codec, not 7zAES, as an encrypted 7z entry's CompressionType
7-Zip writes 7zAES as the first coder of an encrypted folder, in front
of the codec. SevenZipFilePart.GetCompression() looked at the first
coder only, so CompressionType threw InvalidFormatException for every
entry of a 7-Zip-made encrypted archive. Skip the AES filter and report
the first real coder.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-24 12:03:46 -07:00
Adam Hathcock
f83502bd64 Record full XZ follow-up validation and fast-path CPU trace 2026-10-24 13:44:34 +01:00
Adam Hathcock
ba248dc01e Decode asynchronously buffered LZMA2 chunks with the fast CPU path 2026-10-24 13:37:15 +01:00
Adam Hathcock
31f3476fc9 Add native ValueTask memory reads through XZ filter chains 2026-10-24 13:09:51 +01:00
Adam Hathcock
de7a5d9ad4 Avoid duplicate task results in XZ BCJ array reads 2026-10-24 12:54:39 +01:00
Adam Hathcock
d755de5170 Record XZ CPU and allocation trace attribution 2026-10-24 12:45:16 +01:00
Adam Hathcock
f7451966ec Document XZ BCJ pooling evaluation and add benchmarks 2026-10-24 12:42:57 +01:00
Adam Hathcock
bcf245e174 Merge remote-tracking branch 'origin/master' into dependabot/nuget/build/all-dependencies-232486072c 2026-10-24 12:34:23 +01:00
Adam Hathcock
1fc761d5a5 Update dependencies and migrate tests to Microsoft Testing Platform 2026-10-24 12:33:38 +01:00
Adam Hathcock
5c46363f26 Pool XZ BCJ buffers and dispose owned filter chains 2026-10-24 12:24:58 +01:00
Adam Hathcock
0aaf9b92aa Fix streaming XZ BCJ decoding across read boundaries 2026-10-24 12:08:18 +01:00
Adam Hathcock
9c555c41cc Preserve legacy ZIP descriptor width probe 2026-10-24 12:02:27 +01:00
Adam Hathcock
fafbb4a5fe Merge remote-tracking branch 'origin/master' into review/fix-zip64-descriptor-width 2026-10-24 11:57:17 +01:00
Adam Hathcock
ee30126370 Fix ZIP64 streaming data descriptor width parsing 2026-10-24 11:50:31 +01:00
Adam Hathcock
e65e437c3d Merge pull request #1470 from dajiaohuang/fix/zip64-agent-guidance
docs: update non-seekable ZIP64 support guidance
2026-10-22 14:13:41 +01:00
dajiaohuang
7e0384886b docs: update non-seekable ZIP64 support guidance 2026-10-22 18:51:35 +08:00
dependabot[bot]
3a964e3816 Bump the all-dependencies group with 5 updates
Bumps JetBrains.Profiler.SelfApi from 2.5.18 to 2.5.19
Bumps Microsoft.NET.Test.Sdk from 18.10.1 to 18.11.0
Bumps Microsoft.SourceLink.GitHub from 10.0.401 to 10.0.402
Bumps Pure.DI from 2.5.4 to 2.5.5
Bumps System.Text.Encoding.CodePages from 10.0.12 to 10.0.13

---
updated-dependencies:
- dependency-name: JetBrains.Profiler.SelfApi
  dependency-version: 2.5.19
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: all-dependencies
- dependency-name: Microsoft.NET.Test.Sdk
  dependency-version: 18.11.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: all-dependencies
- dependency-name: Microsoft.SourceLink.GitHub
  dependency-version: 10.0.402
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: all-dependencies
- dependency-name: Pure.DI
  dependency-version: 2.5.5
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: all-dependencies
- dependency-name: System.Text.Encoding.CodePages
  dependency-version: 10.0.13
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: all-dependencies
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-10-22 09:40:12 +00:00
Adam Hathcock
cbbf5e8f55 Merge pull request #1466 from adamhathcock/adam/pure-di-2
Refactor archive workflows into focused services and public entry points
2026-10-22 08:23:09 +01:00
Adam Hathcock
b8e81bd3f5 Split ArchiveFactory into focused public entry points 2026-10-21 11:47:47 +01:00
Adam Hathcock
ed29acda67 Remove redundant partial modifiers 2026-10-21 09:53:07 +01:00
Adam Hathcock
068da202e4 Expose default services directly through LibraryDefaults 2026-10-21 09:46:38 +01:00
Adam Hathcock
e21da75de2 Split DI services into focused workflow components 2026-10-21 09:27:47 +01:00
Adam Hathcock
4cc8d6b257 Use generated internal interfaces for DI services 2026-10-21 09:12:42 +01:00
Adam Hathcock
b578325982 Move extension workflows into internal services 2026-10-21 08:57:36 +01:00
Adam Hathcock
740ae8fa89 Refactor factory workflows into internal Pure.DI services 2026-10-21 08:42:00 +01:00
Adam Hathcock
50b7f49054 Merge pull request #1453 from adamhathcock/feature/non-seekable-zip64-writing
Support ZIP64 writing to non-seekable streams
2026-10-20 12:06:00 +01:00
Adam Hathcock
2463488de7 Merge remote-tracking branch 'origin/master' into feature/non-seekable-zip64-writing
# Conflicts:
#	src/SharpCompress/Factories/TarFactory.cs
#	src/SharpCompress/Readers/Tar/TarReader.Factory.cs
#	src/SharpCompress/Readers/Tar/TarReader.cs
#	tests/SharpCompress.Test/Streams/RarLifetimeTests.cs
#	tests/SharpCompress.Test/Streams/SevenZipLifetimeTests.cs
#	tests/SharpCompress.Test/Streams/TarLifetimeTests.cs
2026-10-20 11:41:45 +01:00
Adam Hathcock
0e0dc2a795 Merge pull request #1465 from adamhathcock/adam/release-to-master
Release to master
2026-10-20 11:36:44 +01:00
Adam Hathcock
2d9508755e Merge remote-tracking branch 'origin/master' into adam/release-to-master 2026-10-20 11:21:00 +01:00
Adam Hathcock
799f1e6239 Merge pull request #1462 from adamhathcock/perf/rar-profile-pooling
Rar profile pooling
2026-10-20 11:20:08 +01:00
Adam Hathcock
714a27fd40 Fix RAR checksum handling for empty reads and checksum-free entries 2026-10-20 11:11:43 +01:00