Skip to content

fix: truncate vulnerability descriptions on UTF-8 rune boundaries - #80

Closed
Abhinesh Jha (Abhineshhh) wants to merge 1 commit into
microsoft:mainfrom
Abhineshhh:fix/utf8-truncate-string
Closed

fix: truncate vulnerability descriptions on UTF-8 rune boundaries#80
Abhinesh Jha (Abhineshhh) wants to merge 1 commit into
microsoft:mainfrom
Abhineshhh:fix/utf8-truncate-string

Conversation

@Abhineshhh

Copy link
Copy Markdown
Contributor

Description

truncateString sliced by byte length, which can cut multi-byte UTF-8 (CJK, emoji) mid-rune and store invalid UTF-8 in the DB / JSON reports.

Related Issue

Fixes #79

Changes

  • Truncate on rune boundaries while respecting a max byte budget (including ...)
  • Add regression tests for CJK/emoji/edge max lengths

Checklist

  • task lint passes locally
  • task test passes locally
  • Documentation updated (if applicable)

Byte-based slicing in truncateString could cut multi-byte characters
mid-rune (CJK, emoji), producing invalid UTF-8 stored in the database
and emitted in JSON reports.

Truncate by rune while respecting a max byte budget (including ...),
and add regression tests for multi-byte inputs.

Fixes microsoft#79
@Abhineshhh

Copy link
Copy Markdown
Contributor Author

Closing in favor of a consolidated stack to avoid multi-PR conflicts on the same files.

Superseded by consolidated Trivy stack (UTF-8 truncate is included there).

Please review the replacement PR linked above (Trivy stack or registry stack).

@Abhineshhh

Copy link
Copy Markdown
Contributor Author

Replacement: #87 (Trivy stack).

@Abhineshhh
Abhinesh Jha (Abhineshhh) deleted the fix/utf8-truncate-string branch July 16, 2026 20:14
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.

[Bug]: truncateString can produce invalid UTF-8 in vulnerability descriptions

1 participant