-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Produce valid xml and preserve utf8 characters in attributes #588
Conversation
|
||
class XmlEncode { | ||
public: | ||
enum ForWhat { ForTextNodes, ForAttributes }; | ||
enum ForWhat { ForTextNodes, ForAttributes }; |
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.
y u trailing whitespace
- Minor adjustments to mimic styling of surrounding code P.S.: a .clang-format file would be nice ;-)
When is this going to be in a Catch release? The issue renders JUnit output unusable in many cases... |
This commit fixes the following scenario: * You have a test that compares strings with embedded control characters. * The test fails. * You are using JUnit tests within TeamCity. Before this commit, the JUnit report watcher fails on parsing the XML for two reasons: the control characters are missing a semicolon at the end, and the XML document doesn't specify that it is XML 1.1. XML 1.0 --- what we get if we don't specify an XML version --- doesn't support embedding control characters --- see http://stackoverflow.com/questions/404107/why-are-control-characters-illegal-in-xml for all of the gory details. This is based on PR catchorg#588 by @mrpi
There were a few issues here, and several iterations attempting to address them (thanks for all involved, btw). I'm now not entirely clear if any of it is still outstanding? |
Just tested with Catch v1.5.7. produces this xml: http://www.xmlvalidation.com says:
|
@mrpi If I run your test case against current master, it works. As long as its on Linux. If I try it on Windows, I end up with "Warning C4566: character represented by universal-character-name '\u8A00' cannot be represented in the current code page (1252)" and invalid XML, but I blame that on wrong setting somewhere (which I am not able to find nor google properly). |
Works for me too on macOS (with Clang). |
Could anyone who originally had problems here (@mrpi?, @gatopeich?) confirm or deny whether there are still issues with this? |
XML output looks good now! |
Cool - thanks! |
The XML escaping had three problems:
My patch is not perfect for platforms/source code working with other encodings than ASCII or UTF8. But at least the created XML should be accepted by a valid parser.
Everything else would require C++11 u8""-string literals all over the place or an xml encoder that performs character set conversion.