mirror of
https://github.com/hanzoai/team.git
synced 2026-09-30 01:57:35 +00:00
* 🐛 fix: normalize Unicode filenames in import attachment lookup Fix import failures for files with Japanese dakuten/handakuten characters (e.g., ガ, パ, べ) on macOS. macOS stores filenames in NFD (decomposed) form while Linux/Windows use NFC (composed) form. This mismatch caused attachment lookup failures when zip filenames and JSONL paths used different normalization forms. Changes: - Add NormalizeFilename utility function using golang.org/x/text/unicode/norm - Normalize filenames when building attachment maps from zip files - Normalize paths when looking up attachments in maps - Apply fixes to both server (import.go) and mmctl (validate.go) * avoid duplicating normalizeFilename * add coverage for Korean filenames --------- Co-authored-by: Jesse Hallam <[email protected]> Co-authored-by: Mattermost Build <[email protected]> Co-authored-by: Hanzo Dev <[email protected]>
16 lines
624 B
Go
16 lines
624 B
Go
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
// See LICENSE.txt for license information.
|
|
|
|
package utils
|
|
|
|
import "golang.org/x/text/unicode/norm"
|
|
|
|
// NormalizeFilename normalizes a filename to NFC (composed) form.
|
|
// This ensures consistent string comparison between filesystems that use
|
|
// different Unicode normalization forms (macOS uses NFD, Linux/Windows use NFC).
|
|
// This is particularly important for Japanese dakuten/handakuten characters
|
|
// (e.g., "ガ" can be represented as U+30AC (NFC) or U+30AB + U+3099 (NFD)).
|
|
func NormalizeFilename(name string) string {
|
|
return norm.NFC.String(name)
|
|
}
|