Index: devel/kyua/Makefile =================================================================== --- devel/kyua/Makefile +++ devel/kyua/Makefile @@ -2,7 +2,7 @@ PORTNAME= kyua PORTVERSION= 0.11 -PORTEPOCH= 3 +PORTEPOCH= 4 CATEGORIES= devel MASTER_SITES= https://github.com/jmmv/kyua/releases/download/${PORTNAME}-${PORTVERSION}/ \ LOCAL/jmmv @@ -34,6 +34,8 @@ TEST_BUILD_DEPENDS= atf>=0.21:devel/atf TEST_RUN_DEPENDS= atf>=0.21:devel/atf +EXTRA_PATCHES+= ${FILESDIR}/extra-issue136.patch:-p1 + .include CONFIGURE_ARGS+= --without-doxygen Index: devel/kyua/files/extra-issue136.patch =================================================================== --- /dev/null +++ devel/kyua/files/extra-issue136.patch @@ -0,0 +1,123 @@ +From 0bb14ef5c9493931af01a4bebd7380df1e23c867 Mon Sep 17 00:00:00 2001 +From: Craig Rodrigues +Date: Wed, 30 Sep 2015 17:23:31 -0700 +Subject: [PATCH] Do not write out invalid characters to XML file + +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 +--- + utils/text/operations.cpp | 46 ++++++++++++++++++++++++++---------------- + utils/text/operations_test.cpp | 3 +++ + 3 files changed, 36 insertions(+), 17 deletions(-) + +diff --git a/utils/text/operations.cpp b/utils/text/operations.cpp +index 736e7f3..5a4345d 100644 +--- a/utils/text/operations.cpp ++++ b/utils/text/operations.cpp +@@ -38,6 +38,9 @@ namespace text = utils::text; + + /// Replaces XML special characters from an input string. + /// ++/// The list of XML special characters is specified here: ++/// http://www.w3.org/TR/xml11/#charsets ++/// + /// \param in The input to quote. + /// + /// \return A quoted string without any XML special characters. +@@ -46,25 +49,34 @@ text::escape_xml(const std::string& in) + { + std::ostringstream quoted; + +- const char* delims = "\"&<>'"; // Keep in sync with 'switch' below. +- std::string::size_type start_pos = 0; +- std::string::size_type last_pos = in.find_first_of(delims); +- while (last_pos != std::string::npos) { +- quoted << in.substr(start_pos, last_pos - start_pos); +- switch (in[last_pos]) { +- case '"': quoted << """; break; +- case '&': quoted << "&"; break; +- case '<': quoted << "<"; break; +- case '>': quoted << ">"; break; +- case '\'': quoted << "'"; break; +- default: UNREACHABLE; ++ for (std::string::const_iterator it = in.begin(); ++ it != in.end(); ++it) { ++ unsigned char c = (unsigned char)*it; ++ if (c == '"') { ++ quoted << """; ++ } else if (c == '&') { ++ quoted << "&"; ++ } else if (c == '<') { ++ quoted << "<"; ++ } else if (c == '>') { ++ quoted << ">"; ++ } else if (c == '\'') { ++ quoted << "'"; ++ } else if ((c >= 0x01 && c <= 0x08) || ++ (c >= 0x0B && c <= 0x0C) || ++ (c >= 0x0E && c <= 0x1F) || ++ (c >= 0x7F && c <= 0x84) || ++ (c >= 0x86 && c <= 0x9F)) { ++ // for RestrictedChar characters, escape them ++ // as '&#[decimal ASCII value];' ++ // so that in the XML file we will see the escaped ++ // character. ++ quoted << "&#" << static_cast< std::string::size_type >(*it) ++ << ";"; ++ } else { ++ quoted << *it; + } +- start_pos = last_pos + 1; +- last_pos = in.find_first_of(delims, start_pos); + } +- if (start_pos < in.length()) +- quoted << in.substr(start_pos); +- + return quoted.str(); + } + +diff --git a/utils/text/operations_test.cpp b/utils/text/operations_test.cpp +index 769b7d4..2d5ab36 100644 +--- a/utils/text/operations_test.cpp ++++ b/utils/text/operations_test.cpp +@@ -77,6 +77,7 @@ ATF_TEST_CASE_BODY(escape_xml__no_escaping) + { + ATF_REQUIRE_EQ("a", text::escape_xml("a")); + ATF_REQUIRE_EQ("Some text!", text::escape_xml("Some text!")); ++ ATF_REQUIRE_EQ("\n\t\r", text::escape_xml("\n\t\r")); + } + + +@@ -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&")); + } + +