Skip to content

fix: truncate strings on UTF-8 boundaries in StrEllipsis - #2514

Merged
ansgarbecker merged 1 commit into
HeidiSQL:lazarusfrom
twinn1013:fix-menu-utf8-truncation-crash
Jun 11, 2026
Merged

fix: truncate strings on UTF-8 boundaries in StrEllipsis#2514
ansgarbecker merged 1 commit into
HeidiSQL:lazarusfrom
twinn1013:fix-menu-utf8-truncation-crash

Conversation

@twinn1013

Copy link
Copy Markdown
Collaborator

Fixes #2510

StrEllipsis truncated strings by byte count, which can split a multi-byte UTF-8 character and produce invalid UTF-8. On the Cocoa widgetset that becomes a nil NSString and crashes -[NSMenuItem initWithTitle:] when the result is used as a menu caption (e.g. the data grid quick-filter items built from long non-ASCII cell values).

Switch truncation to UTF8Length/UTF8Copy (LazUTF8, already used by the unit) so it cuts on codepoint boundaries.

StrEllipsis truncated by byte count (SetLength/Copy), which can split a
multi-byte UTF-8 character and produce invalid UTF-8. On the Cocoa
widgetset such a string becomes a nil NSString, which crashes
-[NSMenuItem initWithTitle:] when the result is used as a menu caption
(e.g. the data grid quick-filter items built from long non-ASCII values).

Use UTF8Length/UTF8Copy (LazUTF8, already used here) to cut on codepoint
boundaries.
@twinn1013 twinn1013 added the macos Affects the macOS app bundle label Jun 11, 2026
@ansgarbecker
ansgarbecker merged commit 2174388 into HeidiSQL:lazarus Jun 11, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

macos Affects the macOS app bundle

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants