Skip to content

Commit 72c63cf

Browse files
committed
Update AbstractPathHelpers.cs
1 parent 41c37fa commit 72c63cf

1 file changed

Lines changed: 11 additions & 7 deletions

File tree

src/Core/SecureFolderFS.Core.FileSystem/Helpers/Paths/Abstract/AbstractPathHelpers.cs

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,19 @@ public static ReadOnlySpan<char> RemoveCiphertextExtension(string ciphertextName
3333

3434
// Only normalize if needed. APFS/Android layers NFD-decompose Base4K codepoints,
3535
// but Dokany/WinFsp deliver names in a form where NFC recomposition breaks lookup.
36-
// IsNormalized() lets the string itself determine whether normalization is safe.
37-
if (!nameWithoutExtension.IsNormalized(NormalizationForm.FormC))
36+
if (OperatingSystem.IsAndroid() || OperatingSystem.IsIOS() || OperatingSystem.IsMacOS() || OperatingSystem.IsMacCatalyst())
3837
{
39-
var normalizedLength = nameWithoutExtension.GetNormalizedLength(NormalizationForm.FormC);
40-
var normalized = new char[normalizedLength];
38+
// IsNormalized() lets the string itself determine whether normalization is safe.
39+
// TODO: Fix normalization in Vault V4
40+
if (!nameWithoutExtension.IsNormalized(NormalizationForm.FormC))
41+
{
42+
var normalizedLength = nameWithoutExtension.GetNormalizedLength(NormalizationForm.FormC);
43+
var normalized = new char[normalizedLength];
4144

42-
// NFC-normalize before decoding
43-
if (nameWithoutExtension.TryNormalize(normalized, out var written, NormalizationForm.FormC))
44-
return normalized.AsSpan(0, written);
45+
// NFC-normalize before decoding
46+
if (nameWithoutExtension.TryNormalize(normalized, out var written, NormalizationForm.FormC))
47+
return normalized.AsSpan(0, written);
48+
}
4549
}
4650

4751
return nameWithoutExtension;

0 commit comments

Comments
 (0)