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
Do not write out invalid characters to XML file. #148
Conversation
} else if (c == '>') { | ||
quoted << ">"; | ||
} else if (c == '\'') { | ||
quoted << "'"; |
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.
Why bother respecting all these entities? Why not just use the decimal ASCII value in all cases? The latter would keep the code simpler, and the resulting XML wouldn't depend on the definition of the entities, which are not available in a "plain" XML document.
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.
I respected those entities, because the old code did that.
Changing this behavior to emit ASCII for these characters would be a change
in behavior, and would require updating the utils/text/operations_test:escape_xml__some_escaping unit test.
I didn't want to go down that path, but if you want that, and allow me to change the unit test, I can do that.
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.
OK, I guess it makes sense to leave as you did. I read the spec links you provided and it seems that there is a clear difference between the "special characters" and everything else.
I personally like the named entities better for readability, but the introduction of two behaviors (named entities for these, numeric for the rest) is a bit unfortunate.
This change is missing tests. The existing tests for And super-nitpick: the change description does not follow the guidelines in CONTRIBUTING.md:
|
They are emitting characters which are triggering a kyua bug which causes kyua to emit invalid XML. This invalid XML is causing false failures in Jenkins. On a separate note, kyua needs to be fixed with this: freebsd/kyua#148 or something similar. git-svn-id: svn+ssh://svn.freebsd.org/base/head@291015 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
They are emitting characters which are triggering a kyua bug which causes kyua to emit invalid XML. This invalid XML is causing false failures in Jenkins. On a separate note, kyua needs to be fixed with this: freebsd/kyua#148 or something similar.
// as '&#[decimal ASCII value];' | ||
// so that in the XML file we will see the escaped | ||
// character. | ||
quoted << "&#" << int(*it) << ";"; |
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.
The cast would better be static_cast< std::string::size_type >(*it)
to not make any assumptions on the character/integer sizes.
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.
I added that.
For special characters such as: <, >, or ', write them out to the file as: &#[decimal ASCII value]; Character Written to Appears in Jenkins to encode XML file test result viewer ========= ========== ================== < < < > > > ' ' ' & & & " " " For characters which are listed as RestrictedChar in http://www.w3.org/TR/xml11/#charsets , these characters are completely invalid XML, and cannot even be escaped. Character Written to Appears in Jenkins to encode XML file test result viewer ========= ========== ================== 0x08 &#8;  0x1F &#31;  This will at least generate a valid XML file, but let us see where these restricted characters would appear in the output. Fixes #136
@@ -90,6 +91,8 @@ ATF_TEST_CASE_BODY(escape_xml__some_escaping) | |||
|
|||
ATF_REQUIRE_EQ(""&<>'", text::escape_xml("\"&<>'")); | |||
ATF_REQUIRE_EQ("&&&", text::escape_xml("&&&")); | |||
ATF_REQUIRE_EQ("&#8;&#11;", text::escape_xml("\b\v")); | |||
ATF_REQUIRE_EQ("\t&#127;BAR&", text::escape_xml("\t\x7f""BAR&")); |
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.
What's the point of the double "" in the middle of the argument passed to escape_xml
? Seems unnecessary.
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.
It's needed because otherwise the compiler will think that it is \x7fBA
Committed. I did a manual merge to add a proper entry to |
kyua 0.12 has fix for freebsd/kyua#148 which eliminates invalid XML characters from being written to test reports with "kyua report-junit". git-svn-id: svn+ssh://svn.freebsd.org/base/head@291616 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
kyua 0.12 has fix for freebsd/kyua#148 which eliminates invalid XML characters from being written to test reports with "kyua report-junit".
They are emitting characters which are triggering a kyua bug which causes kyua to emit invalid XML. This invalid XML is causing false failures in Jenkins. On a separate note, kyua needs to be fixed with this: freebsd/kyua#148 or something similar. git-svn-id: svn+ssh://svn.freebsd.org/base/head@291015 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
kyua 0.12 has fix for freebsd/kyua#148 which eliminates invalid XML characters from being written to test reports with "kyua report-junit". git-svn-id: svn+ssh://svn.freebsd.org/base/head@291616 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
Fixes #136