Skip to content

Fix service name formatter deleting tabs/newlines instead of collapsing them - #51

Closed
kayjoosten wants to merge 1 commit into
feature/issue-48-preserve-mdui-uiinfofrom
fix/service-name-tab-stripping
Closed

kayjoosten wants to merge 1 commit into
feature/issue-48-preserve-mdui-uiinfofrom
fix/service-name-tab-stripping

Conversation

@kayjoosten

Copy link
Copy Markdown
Contributor

Problem

While testing the service name display feature, a service name containing a tab or newline between words (e.g. "Name\tWith") rendered as concatenated words ("NameWith") instead of a single space ("Name With").

Root cause

ServiceNameFormatter::format() stripped control/format characters (\p{Cc}\p{Cf}) before collapsing whitespace (\s+) to a single space. Since a tab or newline is itself a control character, it was deleted outright in the first pass instead of ever reaching the whitespace-collapse pass.

Fix

Swapped the order of the two regex passes: whitespace is now collapsed to a single space first, then remaining non-whitespace control/format characters (e.g. zero-width space, BEL) are stripped with no replacement.

Testing

Added regression tests for tab-between-words and newline-between-words. Full suite (43/43) and phpstan pass.

…ng them

Control-character stripping ran before whitespace collapsing, so a tab
or newline between words (itself a control character) was deleted
outright instead of being normalized to a single space, joining
adjacent words together. Swap the order so whitespace is collapsed
first, then remaining control/format characters are stripped.
@kayjoosten

Copy link
Copy Markdown
Contributor Author

Closing - fix has been pushed directly to feature/issue-48-preserve-mdui-uiinfo instead (see PR #49).

@kayjoosten kayjoosten closed this Jul 14, 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.

1 participant