Skip to content
This repository has been archived by the owner on May 15, 2024. It is now read-only.

Fix non-ordinal string comparison. #219

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

reima
Copy link

@reima reima commented Nov 18, 2020

Fixes #218.

The non-ordinal comparison caused file entries with an emoji name to be treated as directories.

DotNetZip treats an entry as a directory if its name ends with "/". This is checked using string.EndsWith(string). That's an issue because string.EndsWith(string) uses the current CultureInfo to check for the suffix. For all cultures I've tested (including CultureInfo.InvariantCulture), the following was true:

"Files/\u26BE".EndsWith("/") == true

\u26BE is the Unicode escape sequence for the character ⚾ (U+26BE BASEBALL), which is somehow ignored by string.EndsWith(string). Other emoji characters are also affected by this, but not all emoji. I've yet to see a pattern here.

Using the overload string.EndsWith(string, StringComparison) with StringComparison.Ordinal fixes this issue.

I've also fixed other calls to string.EndsWith(string) as well as string.StartsWith(string) (which exposes the same behavior with strings beginning with some emoji characters), which are not strictly related to #218, but are probably problematic as well.

The non-ordinal comparison caused file entries with an emoji name to be
treated as directories.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

File named "⚾" is treated as directory
1 participant