Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

FastZip.CreateZip crashes when used with certain buggy Directory enumeration on .NET 5

未关闭
#676 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
25/100
Issue 类型
功能
描述清晰度
基本清楚
活跃度
停滞
技术栈
csharp
领域
tooling

调研方向

从引用的行附近开始检查 FastZip.cs,并查看 CreateZip 如何使用 FileSystemScanner。检查所请求的扩展点和提供的枚举变通方案,然后确认调用方可以针对所描述的 .NET 5 情况提供自定义 scanner,而不会导致 FastZip.CreateZip 失败。

由索引模型根据 Issue 内容生成。

描述

enhancement zip

Not really a bug, more like a feature suggestion.

Steps to reproduce
  1. In .net 5, directory enumeration has bugs with WebDav (https://github.com/dotnet/runtime/issues/46723#issuecomment-928090089), not fixed in .net 6 and with no other immediate official solution in sight;
  2. This causes crashes when calling FastZip.CreateZip as the GetDirectories/GetFiles return invalid data;
  3. A workaround is available - use something like this on the GetDirectories-returned data:
public static string[] FixupNet5Enumeration(string[] items)
{
    return items
        .Select(t => t.TrimEnd('\0'))
        .Where(t => {
            var itemName = Path.GetFileName(t);
            return itemName != "." && itemName != "..";
        })
        .ToArray();
}
  1. SharpZipLib nicely wraps the Directory.GetDirectories call into the FileSystemScanner class. However it is not possible to supply custom FileSystemScanners to FastZip.CreateZip. It would be helpful in this case as I could just copy that class and insert the required fixup calls. It would be necessary to create an interface around FileSystemScanner and to change to public the method

https://github.com/icsharpcode/SharpZipLib/blob/612969e574fd9d922314f24923792e343871f102/src/ICSharpCode.SharpZipLib/Zip/FastZip.cs#L477

What do you think?

Expected behavior

FastZip.CreateZip should offer an override to specify custom FileSystemScanners.

Actual behavior

FastZip.CreateZip throws exception as the paths returned by Directory.GetDirectories are not valid paths.

Version of SharpZipLib

1.3.3

Obtained from (only keep the relevant lines)
  • Package installed using NuGet
主要语言
C#
星标
3.9k
派生
1k
PR 合并指标
30 天内没有已合并 PR

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

icsharpcode/SharpZipLib 的其他 Issue

查看 icsharpcode/SharpZipLib 的全部 Issue

相似的 Issue

更多 C# Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。