From owner-svn-ports-head@freebsd.org Fri Apr 8 15:58:47 2016 Return-Path: Delivered-To: svn-ports-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 2ACD6B084AC; Fri, 8 Apr 2016 15:58:47 +0000 (UTC) (envelope-from lwhsu@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 062691CCF; Fri, 8 Apr 2016 15:58:46 +0000 (UTC) (envelope-from lwhsu@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u38FwkCH072142; Fri, 8 Apr 2016 15:58:46 GMT (envelope-from lwhsu@FreeBSD.org) Received: (from lwhsu@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u38FwkeH072140; Fri, 8 Apr 2016 15:58:46 GMT (envelope-from lwhsu@FreeBSD.org) Message-Id: <201604081558.u38FwkeH072140@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: lwhsu set sender to lwhsu@FreeBSD.org using -f From: Li-Wen Hsu Date: Fri, 8 Apr 2016 15:58:46 +0000 (UTC) To: ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org Subject: svn commit: r412750 - in head/devel/kyua: . files X-SVN-Group: ports-head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-ports-head@freebsd.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: SVN commit messages for the ports tree for head List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 08 Apr 2016 15:58:47 -0000 Author: lwhsu Date: Fri Apr 8 15:58:45 2016 New Revision: 412750 URL: https://svnweb.freebsd.org/changeset/ports/412750 Log: - Fix printing out binary/UTF-8 characters by backporting fix from 0.12 Submitted by: ngie Reviewed by: rodrigc Approved by: jmmv (maintainer) Differential Revision: https://reviews.freebsd.org/D5851 Added: head/devel/kyua/files/patch-issue136 (contents, props changed) Modified: head/devel/kyua/Makefile Modified: head/devel/kyua/Makefile ============================================================================== --- head/devel/kyua/Makefile Fri Apr 8 15:56:03 2016 (r412749) +++ head/devel/kyua/Makefile Fri Apr 8 15:58:45 2016 (r412750) @@ -2,6 +2,7 @@ PORTNAME= kyua PORTVERSION= 0.11 +PORTREVISION= 1 PORTEPOCH= 3 CATEGORIES= devel MASTER_SITES= https://github.com/jmmv/kyua/releases/download/${PORTNAME}-${PORTVERSION}/ \ Added: head/devel/kyua/files/patch-issue136 ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/devel/kyua/files/patch-issue136 Fri Apr 8 15:58:45 2016 (r412750) @@ -0,0 +1,87 @@ +diff --git utils/text/operations.cpp utils/text/operations.cpp +index 736e7f3..5a4345d 100644 +--- utils/text/operations.cpp ++++ 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 utils/text/operations_test.cpp utils/text/operations_test.cpp +index 769b7d4..2d5ab36 100644 +--- utils/text/operations_test.cpp ++++ 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&")); + } + +