fix(junit): escape null control character (#18325)

Fixes https://github.com/microsoft/playwright/issues/18322
This commit is contained in:
Max Schmitt 2022-10-25 14:39:16 -07:00 committed by GitHub
parent 0653692a5b
commit ffc47271f2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 2 deletions

View file

@ -285,7 +285,7 @@ function serializeXML(entry: XMLEntry, tokens: string[], stripANSIControlSequenc
}
// See https://en.wikipedia.org/wiki/Valid_characters_in_XML
const discouragedXMLCharacters = /[\u0001-\u0008\u000b-\u000c\u000e-\u001f\u007f-\u0084\u0086-\u009f]/g;
const discouragedXMLCharacters = /[\u0000-\u0008\u000b-\u000c\u000e-\u001f\u007f-\u0084\u0086-\u009f]/g;
function escape(text: string, stripANSIControlSequences: boolean, isCharacterData: boolean): string {
if (stripANSIControlSequences)

View file

@ -106,6 +106,7 @@ test('should render stdout', async ({ runInlineTest }) => {
console.log(colors.yellow('Hello world'));
console.log('Hello again');
console.error('My error');
console.error('\\0'); // null control character
test.expect("abc").toBe('abcd');
});
`,
@ -116,7 +117,8 @@ test('should render stdout', async ({ runInlineTest }) => {
expect(testcase['system-out'][0]).toContain('[33mHello world[39m\nHello again');
expect(testcase['system-out'][0]).not.toContain('u00');
expect(testcase['system-err'][0]).toContain('My error');
expect(testcase['failure'][0]['_']).toContain(`> 11 | test.expect("abc").toBe('abcd');`);
expect(testcase['system-err'][0]).not.toContain('\u0000'); // null control character
expect(testcase['failure'][0]['_']).toContain(`> 12 | test.expect("abc").toBe('abcd');`);
expect(result.exitCode).toBe(1);
});