Skip to content

TestFilterBuilder builds invalid XMLΒ #491

@jnm2

Description

@jnm2

(Updated)

This implementation mishandles surrogate pairs. Control characters other than tab, carriage return and line feed cannot be represented in XML and should throw, IIRC. (See nunit/nunit3-vs-adapter#484.)

private static string XmlEscape(string text)
{
return text
.Replace("&", "&")
.Replace("\"", """)
.Replace("<", "&lt;")
.Replace(">", "&gt;")
.Replace("'", "&apos;");
}

GetFilter() should be using XmlWriter.Create to a StringWriter. This will not only get us out of the responsibility of implementing the XML spec, it will probably also result in some significant performance gains. (Judging by the chained string.Replace calls.)

(Test names containing control characters cannot be represented in XML without first encoding using base64 or something custom. This will need to be dealt separately with in the framework.)

@nunit/engine-team Does this seem right to you? Can we let @MatthewBeardmore get started on this if he is interested?

Metadata

Metadata

Assignees

Labels

BugV4All issues related to V4 or later - use -label:V4 to get V3 issues

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions