the zip file with '\\' in it's entry.Key make error when run in linux #755

Closed
opened 2026-01-29 22:17:07 +00:00 by claunia · 5 comments
Owner

Originally created by @jackletter on GitHub (Jan 7, 2026).

Although the zip specification stipulates that file path names should use '/' as the separator, there are still non-compliant writes that can cause issues when extracting on Linux. Could we consider uniformly replacing '' with '/' after decoding?

Additional note: I tried implementing the replacement in the CustomDecoder, but if the zip file specifies an encoding, SharpCompress won't invoke the CustomDecoder, preventing me from making the corrections.

        if (Flags.HasFlag(HeaderFlags.Efs))
        {
            Name = ArchiveEncoding.DecodeUTF8(name);
            Comment = ArchiveEncoding.DecodeUTF8(comment);
        }
        else
        {
            Name = ArchiveEncoding.Decode(name);
            Comment = ArchiveEncoding.Decode(comment);
        }
Originally created by @jackletter on GitHub (Jan 7, 2026). Although the zip specification stipulates that file path names should use '/' as the separator, there are still non-compliant writes that can cause issues when extracting on Linux. Could we consider uniformly replacing '\' with '/' after decoding? Additional note: I tried implementing the replacement in the CustomDecoder, but if the zip file specifies an encoding, SharpCompress won't invoke the CustomDecoder, preventing me from making the corrections. ```csharp if (Flags.HasFlag(HeaderFlags.Efs)) { Name = ArchiveEncoding.DecodeUTF8(name); Comment = ArchiveEncoding.DecodeUTF8(comment); } else { Name = ArchiveEncoding.Decode(name); Comment = ArchiveEncoding.Decode(comment); } ```
Author
Owner

@adamhathcock commented on GitHub (Jan 7, 2026):

It something making a zip with \ in the path in SharpCompress? If something is doing this, I don't want to account for it with code.

Maybe the encoding method should have more options?

@adamhathcock commented on GitHub (Jan 7, 2026): It something making a zip with `\` in the path in SharpCompress? If something is doing this, I don't want to account for it with code. Maybe the encoding method should have more options?
Author
Owner

@jackletter commented on GitHub (Jan 7, 2026):

Users may use various programs to compress ZIP file packages, which is beyond our control. As a service provider, we must strive to be as compatible as possible with users' files. @adamhathcock

@jackletter commented on GitHub (Jan 7, 2026): Users may use various programs to compress ZIP file packages, which is beyond our control. As a service provider, we must strive to be as compatible as possible with users' files. @adamhathcock
Author
Owner

@jackletter commented on GitHub (Jan 7, 2026):

The simplest approach is to make the ArchiveEncoding.DecodeUTF8 method virtual. This way, I can inherit from ArchiveEncoding and override DecodeUTF8 to internally replace '\' with '/'.

@jackletter commented on GitHub (Jan 7, 2026): The simplest approach is to make the ArchiveEncoding.DecodeUTF8 method virtual. This way, I can inherit from ArchiveEncoding and override DecodeUTF8 to internally replace '\\' with '/'.
Author
Owner

@adamhathcock commented on GitHub (Jan 7, 2026):

Users may use various programs to compress ZIP file packages, which is beyond our control. As a service provider, we must strive to be as compatible as possible with users' files. @adamhathcock

Disagree. Keys are dumb strings and whatever produces should confirm to spec. If the programs don't, it's not up to SharpCompress to fix it. People can do things themselves with SC though.

The simplest approach is to make the ArchiveEncoding.DecodeUTF8 method virtual. This way, I can inherit from ArchiveEncoding and override DecodeUTF8 to internally replace '' with '/'.

It is the simplest, however might not be the best.

@adamhathcock commented on GitHub (Jan 7, 2026): > Users may use various programs to compress ZIP file packages, which is beyond our control. As a service provider, we must strive to be as compatible as possible with users' files. [@adamhathcock](https://github.com/adamhathcock) Disagree. Keys are dumb strings and whatever produces should confirm to spec. If the programs don't, it's not up to SharpCompress to fix it. People can do things themselves with SC though. > The simplest approach is to make the ArchiveEncoding.DecodeUTF8 method virtual. This way, I can inherit from ArchiveEncoding and override DecodeUTF8 to internally replace '\' with '/'. It is the simplest, however might not be the best.
Author
Owner

@jackletter commented on GitHub (Jan 7, 2026):

So please merge the pull request, so I won't have to duplicate SharpCompress source code internally.

@jackletter commented on GitHub (Jan 7, 2026): So please merge the pull request, so I won't have to duplicate SharpCompress source code internally.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/sharpcompress#755