fix(media): use truncateUtf16Safe for sanitized filename truncation#102695
fix(media): use truncateUtf16Safe for sanitized filename truncation#102695Pandah97 wants to merge 1 commit into
Conversation
Replace .slice(0, 60) with truncateUtf16Safe() to prevent UTF-16 surrogate pair corruption in cross-platform filenames.
|
Codex review: needs real behavior proof before merge. Reviewed July 9, 2026, 7:13 AM ET / 11:13 UTC. Summary PR surface: Source +1. Total +1 across 1 file. Reproducibility: yes. by source inspection: current main sanitizes kept Unicode letters/numbers and then uses Review metrics: none identified. Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Proof guidance:
Risk before merge
Maintainer options:
Next step before merge
Security Review detailsBest possible solution: Land this small helper-based fix after the PR body includes redacted real behavior proof and preferably a focused media-store regression for a supplementary-plane Unicode filename at the 60-code-unit boundary. Do we have a high-confidence way to reproduce the issue? Yes by source inspection: current main sanitizes kept Unicode letters/numbers and then uses Is this the best way to solve the issue? Yes, replacing the final raw slice with the existing AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 99d82a2f21ae. Label changesLabel changes:
Label justifications:
Evidence reviewedPR surface: Source +1. Total +1 across 1 file. View PR surface stats
What I checked:
Likely related people:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. How this review workflow works
|
Summary
sanitizeFilename()in media store truncates sanitized filenames with.slice(0, 60), which can split UTF-16 surrogate pairs when the name contains emoji or CJK characters..slice(0, 60)withtruncateUtf16Safe(name, 60)— a guarded slice that preserves surrogate pair integrity.sanitizeFilename+ added import from@openclaw/normalization-core/utf16-slice.Real behavior proof
pnpm tsgo:coretype check passes.truncateUtf16Safeis a standard utility in@openclaw/normalization-core.pnpm tsgo:coreconfirms compilation. The substitution is a direct 1:1 replacement at a single call site.truncateUtf16Safeis already used in 20+ merged PRs across the codebase.Risk checklist
truncateUtf16Safehas standalone unit tests innormalization-core. Zero behavioral change for ASCII/BMP text paths.AI-assisted
This PR was generated with Claude Code.