NormalizeStoredFileName trims surrounding whitespace, strips control characters, and truncates the name to the durable storage byte limit without splitting UTF-8 runes.
(name string)
| 90 | // characters, and truncates the name to the durable storage byte limit |
| 91 | // without splitting UTF-8 runes. |
| 92 | func NormalizeStoredFileName(name string) string { |
| 93 | name = strings.Map(func(r rune) rune { |
| 94 | if unicode.IsControl(r) { |
| 95 | return -1 |
| 96 | } |
| 97 | return r |
| 98 | }, name) |
| 99 | name = strings.TrimSpace(name) |
| 100 | return truncateUTF8Bytes(name, MaxStoredFileNameBytes) |
| 101 | } |
| 102 | |
| 103 | // PrepareStoredFile normalizes the display name, rejects empty normalized |
| 104 | // names, and classifies the file bytes using detectName when provided, so |
no test coverage detected