From patchwork Sat Sep 30 03:46:21 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Theodore Ts'o X-Patchwork-Id: 9979103 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 266B060327 for ; Sat, 30 Sep 2017 03:46:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 171ED298D9 for ; Sat, 30 Sep 2017 03:46:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0C161298DB; Sat, 30 Sep 2017 03:46:33 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2726A298D9 for ; Sat, 30 Sep 2017 03:46:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752664AbdI3Dq3 (ORCPT ); Fri, 29 Sep 2017 23:46:29 -0400 Received: from imap.thunk.org ([74.207.234.97]:47604 "EHLO imap.thunk.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752592AbdI3Dq2 (ORCPT ); Fri, 29 Sep 2017 23:46:28 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=thunk.org; s=ef5046eb; h=Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: MIME-Version:Content-Type:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=6Gqr4jnMQd0LwQN1xnSylF19qQwXItlJU7FAJMnBHts=; b=DhMaZ/IDb2HXY4dRTwDlbKlCGF WPw5vlXgwKdZKbekSN4tJsekEDkSPVZCQpbqbr1ysLTLj0hbjdoBxq4It+DOElikfpCctOqN3Q99V 8H5/Ceos2oYWYSXMNSbPZpCzUwxB59G7PldxUNTjvM1ZktAtXmYsSepulcvQCPNuJvQU=; Received: from root (helo=callcc.thunk.org) by imap.thunk.org with local-esmtp (Exim 4.89) (envelope-from ) id 1dy8jS-0000pp-NS; Sat, 30 Sep 2017 03:46:26 +0000 Received: by callcc.thunk.org (Postfix, from userid 15806) id AEB61C00830; Fri, 29 Sep 2017 23:46:25 -0400 (EDT) From: Theodore Ts'o To: fstests@vger.kernel.org Cc: Theodore Ts'o , Dmitry Monakhov Subject: [PATCH] report: encode XML Character Entities in xUnit report Date: Fri, 29 Sep 2017 23:46:21 -0400 Message-Id: <20170930034621.3036-1-tytso@mit.edu> X-Mailer: git-send-email 2.11.0.rc0.7.gbe5a750 X-SA-Exim-Connect-IP: X-SA-Exim-Mail-From: tytso@thunk.org X-SA-Exim-Scanned: No (on imap.thunk.org); SAEximRunCond expanded to false Sender: fstests-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: fstests@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Since the xUnit report is an XML document, special XML characters such as '<', '>', '&', etc. have to be encoded as "<", ">", etc. Otherwise programs parsing something like this: Will get choke the unescaped '<' character in the skipped message. Signed-off-by: Theodore Ts'o Cc: Dmitry Monakhov --- common/report | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/common/report b/common/report index 15a63db8..bb689836 100644 --- a/common/report +++ b/common/report @@ -25,6 +25,15 @@ REPORT_ENV_LIST="$REPORT_ENV_LIST OVL_UPPER" REPORT_ENV_LIST="$REPORT_ENV_LIST OVL_LOWER" REPORT_ENV_LIST="$REPORT_ENV_LIST OVL_WORK" +encode_xml() +{ + sed -e 's/&/\&/g' \ + -e 's/>/\>/g' \ + -e 's/" >> $report else echo -e "\t\t" >> $report @@ -103,20 +112,20 @@ _xunit_make_testcase_report() if [ -s $seqres.full ]; then echo -e "\t\t" >> $report printf '>$report - cat $seqres.full | tr -dc '[:print:][:space:]' >>$report + cat $seqres.full | tr -dc '[:print:][:space:]' | encode_xml >>$report printf ']]>\n' >>$report echo -e "\t\t" >> $report fi if [ -f $seqres.dmesg ]; then echo -e "\t\t" >> $report printf '>$report - cat $seqres.dmesg | tr -dc '[:print:][:space:]' >>$report + cat $seqres.dmesg | tr -dc '[:print:][:space:]' | encode_xml >>$report printf ']]>\n' >>$report echo -e "\t\t" >> $report elif [ -s $seqres.out.bad ]; then echo -e "\t\t" >> $report printf '>$report - $diff $seq.out $seqres.out.bad >>$report + $diff $seq.out $seqres.out.bad | encode_xml >>$report printf ']]>\n' >>$report echo -e "\t\t" >> $report fi