Skip to content

Replace non-printable characters in display names #4813

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

sbrannen
Copy link
Member

@sbrannen sbrannen commented Aug 6, 2025

Prior to this commit, display names were "sanitized" before they were printed via the ConsoleLauncher (#1713), and text-based arguments in display names for parameterized tests were quoted and escaped (#4716). However, there was still the chance that display names could contain control characters such as CR or LF.

To address that, this commit introduces support for automatically replacing non-printable characters in any display name passed to one of the constructors for AbstractTestDescriptor. Doing so automatically covers all display names in Jupiter, @SuiteDisplayName, and any other test engines that subclass AbstractTestDescriptor, which should cover most common use cases.

Specifically, the following replacements are performed.

  • \r -> <CR>
  • \n -> <LF>
  • ISO control character -> � (Unicode replacement character)

This commit also removes the special handling of ISO control characters from QuoteUtils, since this is now handled within AbstractTestDescriptor.

Prior to this commit, display names were "sanitized" before they were
printed via the ConsoleLauncher (junit-team#1713), and text-based arguments in
display names for parameterized tests were quoted and escaped (junit-team#4716).
However, there was still the chance that display names could contain
control characters such as CR or LF.

To address that, this commit introduces support for automatically
replacing non-printable characters in any display name passed to one of
the constructors for AbstractTestDescriptor. Doing so automatically
covers all display names in JUnit Jupiter, @⁠SuiteDisplayName, and any
other test engines that subclass AbstractTestDescriptor, which should
cover most common use cases.

Specifically, the following replacements are performed.

- \r -> <CR>
- \n -> <LF>
- ISO control character -> � (Unicode replacement character)

This commit also removes the special handling of ISO control characters
from QuoteUtils, since this is now handled in AbstractTestDescriptor.

See junit-team#1713
See junit-team#4716
Closes junit-team#4714
@sbrannen sbrannen force-pushed the issues/4714-replace-non-printable-characters-in-display-names branch from d118523 to 87eb2f6 Compare August 7, 2025 10:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Replace non-printable characters in display names
1 participant