fix(meshcore): preserve parentheses and emoji in device name on save (#3450)#3451
Conversation
…3450) The MeshCore name sanitizer used an `[a-zA-Z0-9\s\-_]` allow-list, so saving a companion's Device Name silently deleted parentheses, emoji, and other Unicode. Rework sanitizeName to drop ONLY control characters (C0 + DEL) by code point — this still removes CR/LF/tab that would break the line-based repeater serial CLI (`set name <name>`) — while preserving printable Unicode. The result is capped to the 32-byte device name field by UTF-8 byte length, truncating on a code-point boundary so a multi-byte character is never split. Tests cover: parentheses + emoji preserved, control chars stripped, whitespace trimmed, 32-byte cap without splitting a multi-byte char, and empty-after-strip rejection. Full suite: 6395 passing. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Claude finished @Yeraze's task —— View job PR Review Complete ✅I've completed my review of this pull request. Here's my comprehensive feedback: Todo List:
🟢 Overall AssessmentThis is a well-implemented fix that properly addresses the Unicode stripping issue while maintaining security and robustness. The code quality is high and follows the repository's conventions. ✅ Code Quality & Best PracticesStrengths:
Minor observations:
🔒 Security Considerations✅ Excellent security posture:
🚀 Performance Considerations✅ Performance is appropriate:
🧪 Test Coverage✅ Excellent test coverage: The new test suite (
Test quality highlights:
🐛 Potential Issues🟡 Minor considerations:
📋 Recommendations
🎯 SummaryThis PR successfully fixes the Unicode stripping issue while maintaining security and adding robust test coverage. The implementation correctly balances user experience (preserving emoji/parentheses) with system security (removing control characters). The code follows TypeScript and repository best practices and includes comprehensive tests. Verdict: ✅ APPROVE - Well-implemented fix with excellent test coverage. |
Summary
Closes #3450. Editing a MeshCore companion's Device Name (Source → Configuration) silently stripped parentheses, emoji, and other Unicode the moment Save was pressed.
Root cause
MeshCoreManager.sanitizeName()used an allow-list:That deletes anything outside
[A-Za-z0-9 _-]— so(,), and emoji were dropped. (The route just.trim()s and the frontend sends raw input, so this was the only stripping point.)Fix
Rework
sanitizeNameto drop only control characters (C0 controls + DEL) by code point — which still removes CR/LF/tab that would break the line-based repeater serial CLI (set name <name>) — while preserving printable Unicode (parentheses, emoji, punctuation). The result is capped to the device's 32-byte name field by UTF-8 byte length, truncating on a code-point boundary so a multi-byte character is never split. (For ASCII names this is identical to the old 32-char cap — no regression.)Testing
New
meshcoreManager.deviceName.test.ts: parentheses + emoji preserved, control chars (CR/LF/tab/NUL) stripped, surrounding whitespace trimmed, 32-byte cap without splitting a multi-byte emoji, and empty-after-strip rejection.Full Vitest suite: 6395 passing, 0 failures.
🤖 Generated with Claude Code