Skip to content

Commit

Permalink
Escape <> characters in suite name
Browse files Browse the repository at this point in the history
Fixes: dorny#235
  • Loading branch information
wingyplus committed Mar 13, 2023
1 parent e9fa2f5 commit 2adcff8
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/parsers/jest-junit/jest-junit-parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export class JestJunitParser implements TestParser {
junit.testsuites.testsuite === undefined
? []
: junit.testsuites.testsuite.map(ts => {
const name = ts.$.name.trim()
const name = this.escapeCharacters(ts.$.name.trim())
const time = parseFloat(ts.$.time) * 1000
const sr = new TestSuiteResult(name, this.getGroups(ts), time)
return sr
Expand Down Expand Up @@ -118,4 +118,8 @@ export class JestJunitParser implements TestParser {
(this.assumedWorkDir = getBasePath(path, this.options.trackedFiles))
)
}

private escapeCharacters(s: string): string {
return s.replace(/([<>])/g, '\\$1')
}
}

0 comments on commit 2adcff8

Please sign in to comment.