Skip to content
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

fix: remove ansi escape sequences from escaped xunit output #4527

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

trieloff
Copy link

@trieloff trieloff commented Dec 2, 2020

Requirements

  • Filling out the template is required. Any pull request that does not include enough information to be reviewed in a timely manner may be closed at the maintainers' discretion.
  • All new code requires tests to ensure against regressions.

Description of the Change

The utils.escape function is amended to strip the escape sequence using a regular expression.

Alternate Designs

  • patch the underlying he library: dismissed because the direct fix is likely faster to become usable
  • filter the output before running he: dismissed because the correct escaping in JavaScript is harder to find
  • filter out all invalid XML characters: dismissed because this is not a problem observed with other characters

Why should this be in core?

The xunit reporter is in core and should not be buggy

Benefits

xunit reporter output can be consumed by tools that expect valid XML

Possible Drawbacks

Tools that process the XML as plain (unicode) text (unlikely) can no longer see the ANSI escape sequence.

Applicable issues

fixes #4526

This is a bug fix (patch release)

@coveralls
Copy link

Coverage Status

Coverage remained the same at 94.143% when pulling d417538 on trieloff:issue/4526 into bc8ce05 on mochajs:master.

Copy link
Member

@outsideris outsideris left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't there a way to escape or remove all invalid characters for XML?

lib/utils.js Outdated Show resolved Hide resolved
@juergba
Copy link
Member

juergba commented Mar 9, 2021

There is a related xunit issue #3586.

@juergba juergba changed the title remove ansi escape sequences from escaped output (fixes #4526) xunit: remove ansi escape sequences from escaped output Mar 9, 2021
@github-actions
Copy link

github-actions bot commented Jul 9, 2021

This PR hasn't had any recent activity, and I'm labeling it stale. Remove the label or comment or this PR will be closed in 14 days. Thanks for contributing to Mocha!

@github-actions github-actions bot added the stale this has been inactive for a while... label Jul 9, 2021
@trieloff
Copy link
Author

This issue has been hanging around for 8 months now, and I'm unsure what I can do to get it moving again. There is an open thread that has multiple possible solutions to the problem, but no expression of preference from the Mocha team.

@JoshuaKGoldberg
Copy link
Member

👋 coming back to this @trieloff, are you still interested in working on this PR? As of #5027 there are again maintainers who can review it now. No worries if you no longer have time - but if you do that'd be great!

@trieloff
Copy link
Author

trieloff commented Dec 8, 2023

Hi @JoshuaKGoldberg – that's unexpected – but not unwelcome. I'm happy to rebase the PR to the latest main. Do you want to reopen this PR or have me create a new one?

@JoshuaKGoldberg
Copy link
Member

JoshuaKGoldberg commented Dec 8, 2023

Great! Let's go ahead and reopen this one.

We also discussed that we don't like the requirement of rebasing, so if you want to do a more casual merge that works too. Whatever's easiest on your end. 🙂

Copy link

linux-foundation-easycla bot commented Dec 8, 2023

CLA Signed

The committers listed above are authorized under a signed CLA.

@trieloff
Copy link
Author

trieloff commented Jan 3, 2024

Ok, let me get that CLA signed, then.

@JoshuaKGoldberg JoshuaKGoldberg added status: in triage a maintainer should (re-)triage (review) this issue semver-patch implementation requires increase of "patch" version number; "bug fixes" and removed stale this has been inactive for a while... labels Mar 2, 2024
@JoshuaKGoldberg JoshuaKGoldberg changed the title xunit: remove ansi escape sequences from escaped output fix: remove ansi escape sequences from escaped xunit output Mar 4, 2024
@trieloff
Copy link
Author

trieloff commented May 6, 2024

  • CLA has been signed (thanks, corporate overlords)
  • master has been merged
  • conflicts have been resolved

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
semver-patch implementation requires increase of "patch" version number; "bug fixes" status: in triage a maintainer should (re-)triage (review) this issue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

🐛 Bug: xunit reporter does not strip ansi escape sequences, leading to invalid XML
5 participants