Skip to content

fix: truncate SanitizePath on a UTF-8 rune boundary - #14

Closed
MrBeldum wants to merge 1 commit into
go-pkgz:masterfrom
MrBeldum:fix/sanitize-path-utf8
Closed

MrBeldum wants to merge 1 commit into
go-pkgz:masterfrom
MrBeldum:fix/sanitize-path-utf8

Conversation

@MrBeldum

@MrBeldum MrBeldum commented Oct 5, 2026

Copy link
Copy Markdown

Summary

SanitizePath capped the result at 1024 bytes. When the cut landed inside a multi-byte rune, the returned path was invalid UTF-8 (e.g. a trailing �).

After the byte-length truncate, trim trailing bytes until the string is valid UTF-8 so callers never get a split rune.

Test plan

  • Added TestSanitizePathUTF8Boundary
  • go test -run TestSanitizePath ./...

@MrBeldum
MrBeldum requested a review from umputun as a code owner October 5, 2026 21:02
@umputun umputun closed this Oct 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants