-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
base: main
Are you sure you want to change the base?
Replace non-printable characters in display names #4813
Conversation
d118523
to
87eb2f6
Compare
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
87eb2f6
to
3bee7af
Compare
@sormuras, I already used Japanese text in the test, but I just added (and force pushed) Thai text in the test. And I had already used an emoji. So I think we are adequately testing support for multi-byte characters. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Escape implementation based on char
and associated tests look good.
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 subclassAbstractTestDescriptor
, which should cover most common use cases.Specifically, the following replacements are performed.
\r
-><CR>
\n
-><LF>
This commit also removes the special handling of ISO control characters from
QuoteUtils
, since this is now handled withinAbstractTestDescriptor
.ConsoleLauncher
#1713