From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 69ACFA0032; Fri, 24 Jun 2022 10:01:06 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0CD9940A8A; Fri, 24 Jun 2022 10:01:06 +0200 (CEST) Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by mails.dpdk.org (Postfix) with ESMTP id 7F22A40A87 for ; Fri, 24 Jun 2022 10:01:04 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1656057664; x=1687593664; h=date:from:to:cc:subject:message-id:references: mime-version:content-transfer-encoding:in-reply-to; bh=z/13xl9Di4sBjyf5FMxQMVAiZ94NtH15IU/aGUk4niE=; b=NAQx/4TxFRIJD6/jBxYL8WWhlZzzqsUn5hByiH2BlVePDgfqFekiF1Ks nJvxetbpr5mKcOX4Y13R+wFZBSiJ7w2d+F6jP2gdcdq/xEiF68XEED8qK 9H2NhWyn1pqfkkV/xXU6yDC6qWbEdQVQuCgSR109F/QOr1Ib2d1VuChMD FnV+dN3ETHIbIpkbq+QBm4x/65GhsH0zBijX7mdFqjpXkDem7yx6M5rts XmkZH7vIMdnBFh9eXiYvsahVtyoW7fuROXmpyI5qvZL6iX62UI1OSmtOF RpIuaxN9+duzLpcEXh8j/VHB18iNBNxPsDT8ei8wN3GAgu3YMZbT4F2NS g==; X-IronPort-AV: E=McAfee;i="6400,9594,10387"; a="342637503" X-IronPort-AV: E=Sophos;i="5.92,218,1650956400"; d="scan'208";a="342637503" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Jun 2022 01:00:43 -0700 X-IronPort-AV: E=Sophos;i="5.92,218,1650956400"; d="scan'208";a="615895793" Received: from bricha3-mobl.ger.corp.intel.com ([10.252.25.171]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-SHA; 24 Jun 2022 01:00:42 -0700 Date: Fri, 24 Jun 2022 09:00:38 +0100 From: Bruce Richardson To: Morten =?iso-8859-1?Q?Br=F8rup?= Cc: Stephen Hemminger , dev@dpdk.org, ciara.power@intel.com, fengchengwen@huawei.com Subject: Re: [RFC PATCH 2/6] telemetry: fix escaping of invalid json characters Message-ID: References: <20220623164245.561371-1-bruce.richardson@intel.com> <20220623164245.561371-3-bruce.richardson@intel.com> <98CBD80474FA8B44BF855DF32C47DC35D8716B@smartserver.smartshare.dk> <20220623113934.372b059e@hermes.local> <98CBD80474FA8B44BF855DF32C47DC35D8716C@smartserver.smartshare.dk> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <98CBD80474FA8B44BF855DF32C47DC35D8716C@smartserver.smartshare.dk> X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org On Thu, Jun 23, 2022 at 08:48:21PM +0200, Morten Brørup wrote: > > From: Stephen Hemminger [mailto:stephen@networkplumber.org] > > Sent: Thursday, 23 June 2022 20.40 > > > > On Thu, 23 Jun 2022 20:34:07 +0200 > > Morten Brørup wrote: > > > > > > From: Bruce Richardson [mailto:bruce.richardson@intel.com] > > > > Sent: Thursday, 23 June 2022 18.43 > > > > > > > > For string values returned from telemetry, escape any values that > > > > cannot > > > > normally appear in a json string. According to the json spec[1], > > the > > > > characters than need to be handled are control chars (char value < > > > > 0x20) > > > > and '"' and '\' characters. > > > > > > Correct. Other chars are optional to escape. > > > > For json_writer (which I wrote for iproute2 and could have been used > > here). > > The switch handles: \t \n \r \f \b \\ " ' as special cases. > > RFC 8259 chapter 7 says: > > All Unicode characters may be placed within the > quotation marks, except for the characters that MUST be escaped: > quotation mark, reverse solidus, and the control characters (U+0000 > through U+001F). > > I have no preference for either, as long as '/' and other non-control characters are not (unnecessarily) escaped. > > Using tested and maintained code like json_writer could be beneficial. If you hold the copyright, there should be no license issues. > I will take a look at json_writer.