From patchwork Sat Sep 10 08:45:14 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Rodger Combs X-Patchwork-Id: 526 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.140.134 with SMTP id o128csp694275vsd; Sat, 10 Sep 2016 01:45:39 -0700 (PDT) X-Received: by 10.194.20.65 with SMTP id l1mr7677637wje.71.1473497139056; Sat, 10 Sep 2016 01:45:39 -0700 (PDT) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id m2si6632540wjj.132.2016.09.10.01.45.37; Sat, 10 Sep 2016 01:45:39 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 81508689D6B; Sat, 10 Sep 2016 11:45:17 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-oi0-f65.google.com (mail-oi0-f65.google.com [209.85.218.65]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id B0929689CC9 for ; Sat, 10 Sep 2016 11:45:10 +0300 (EEST) Received: by mail-oi0-f65.google.com with SMTP id a144so5792063oii.1 for ; Sat, 10 Sep 2016 01:45:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=mbptJLgKqiK+Cy8pMXaEwxdCL4l8QAIucNF8eqO4ue8=; b=eWs0MRiaWmdWjDeE06pDBFc68ta7F1lnpZUCc4U0RPoZD6J30Otn+UL9pO5EVKJfLe 3edaU4rkvebVezOmkIHMwljDn4PvDizq/d3ZgsU7Ho+JXRekc8RKW4lw0iP+qNx/+16I uU1aXk8X/T6l71Vb043dRHeZaG+Ks0PECfyWAoGFpqUYtqTj5exJ8Qd6J5EITAmp4lWB c2lXzVR/CqMcuKcuFayvdXK1cWa7Pt9McJ7dnb56ysnS6SzaLdUS/IicAz4N3WtfGDtm mM4qIrgu7YtdpdExRNlUXJ4Urs/BFGtBpoyHvocifxyWbed+3QEHXchKlpRsoP9Vo+yS cjVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=mbptJLgKqiK+Cy8pMXaEwxdCL4l8QAIucNF8eqO4ue8=; b=C/Rr0OT/PWl3ZfKfPBdpbKuLqf+OL48LUZvj+mcX9SSWAbijKKDi6VW5y8T//aiR9x 93rd7zZASfjY1Cl3o895qPb8nZKR5aRh56REuB/FcZ4AmhxQNChjl0Rje7tbaLx9fIyA MSII/tdaDsR+vv0rkUzEfdMSOhZQDzgTGmyTS2eKtyKE4i3K0gBOiun/qBVqC5ZEmci8 OmpPG2cMWfpppPIC7TiW076Tq49yttKaICA5wXCRq8ZOF0OKUBs3UW1yitoHmYno2R2S 7G1aAMGvJZwIhHHAZfDv/LOIAUYFmKkBIh+eGED1XPLMEvqNZGT4rYAdeIGb25Fctyzy rqRg== X-Gm-Message-State: AE9vXwNEpQaz22QSmh9pbnOCCSZDr80g0fPRGzpdHO9agTDgr6odc5Qcn9ZsbpJZkXddjA== X-Received: by 10.202.104.224 with SMTP id o93mr12452724oik.18.1473497120433; Sat, 10 Sep 2016 01:45:20 -0700 (PDT) Received: from Rodgers-MacBook-Pro.local.net (c-73-209-137-129.hsd1.il.comcast.net. [73.209.137.129]) by smtp.gmail.com with ESMTPSA id z125sm8849512itc.0.2016.09.10.01.45.19 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 10 Sep 2016 01:45:19 -0700 (PDT) From: Rodger Combs To: ffmpeg-devel@ffmpeg.org Date: Sat, 10 Sep 2016 03:45:14 -0500 Message-Id: <20160910084515.11048-2-rodger.combs@gmail.com> X-Mailer: git-send-email 2.10.0 In-Reply-To: <20160910084515.11048-1-rodger.combs@gmail.com> References: <20160910084515.11048-1-rodger.combs@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 2/3] ffprobe: switch xml_escape_str to use av_bprint_escape X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" This now escapes single-quotes, so the test reference is updated. --- ffprobe.c | 25 ++++++------------------- tests/ref/fate/ffprobe_xml | 2 +- 2 files changed, 7 insertions(+), 20 deletions(-) diff --git a/ffprobe.c b/ffprobe.c index 657867d..70f2ce6 100644 --- a/ffprobe.c +++ b/ffprobe.c @@ -1571,21 +1571,10 @@ static av_cold int xml_init(WriterContext *wctx) return 0; } -static const char *xml_escape_str(AVBPrint *dst, const char *src, void *log_ctx) +static const char *xml_escape_str(AVBPrint *dst, const char *src) { - const char *p; - - for (p = src; *p; p++) { - switch (*p) { - case '&' : av_bprintf(dst, "%s", "&"); break; - case '<' : av_bprintf(dst, "%s", "<"); break; - case '>' : av_bprintf(dst, "%s", ">"); break; - case '"' : av_bprintf(dst, "%s", """); break; - case '\'': av_bprintf(dst, "%s", "'"); break; - default: av_bprint_chars(dst, *p, 1); - } - } - + av_bprint_clear(dst); + av_bprint_escape(dst, src, NULL, AV_ESCAPE_MODE_XML, AV_ESCAPE_FLAG_ESCAPE_DOUBLE_QUOTE); return dst->str; } @@ -1660,14 +1649,12 @@ static void xml_print_str(WriterContext *wctx, const char *key, const char *valu if (section->flags & SECTION_FLAG_HAS_VARIABLE_FIELDS) { XML_INDENT(); - printf("<%s key=\"%s\"", - section->element_name, xml_escape_str(&buf, key, wctx)); - av_bprint_clear(&buf); - printf(" value=\"%s\"/>\n", xml_escape_str(&buf, value, wctx)); + printf("<%s key=\"%s\"", section->element_name, xml_escape_str(&buf, key)); + printf(" value=\"%s\"/>\n", xml_escape_str(&buf, value)); } else { if (wctx->nb_item[wctx->level]) printf(" "); - printf("%s=\"%s\"", key, xml_escape_str(&buf, value, wctx)); + printf("%s=\"%s\"", key, xml_escape_str(&buf, value)); } av_bprint_finalize(&buf, NULL); diff --git a/tests/ref/fate/ffprobe_xml b/tests/ref/fate/ffprobe_xml index b51b0c6..d19847b 100644 --- a/tests/ref/fate/ffprobe_xml +++ b/tests/ref/fate/ffprobe_xml @@ -51,7 +51,7 @@ - +