[FFmpeg-devel] [PATCH v5 1/4] avutil/{avstring, bprint}: add XML escaping from ffprobe to avutil

Jan Ekström jeebjp at gmail.com
Fri Feb 26 21:14:05 EET 2021


On Fri, Feb 26, 2021 at 9:00 PM Jan Ekström <jeebjp at gmail.com> wrote:
>
> On Fri, Feb 26, 2021 at 7:54 PM Michael Niedermayer
> <michael at niedermayer.cc> wrote:
> >
> > On Mon, Feb 22, 2021 at 03:19:11PM +0200, Jan Ekström wrote:
> > > From: Stefano Sabatini <stefasab at gmail.com>
> > >
> > > Base escaping only escapes values required for base character data
> > > according to part 2.4 of XML, and if additional flags are added
> > > single and double quotes can additionally be escaped in order
> > > to handle single and double quoted attributes.
> > > ---
> > >  libavutil/avstring.h | 14 ++++++++++++++
> > >  libavutil/bprint.c   | 29 +++++++++++++++++++++++++++++
> > >  libavutil/version.h  |  2 +-
> > >  tools/ffescape.c     |  7 +++++--
> > >  4 files changed, 49 insertions(+), 3 deletions(-)
> >
> > breaks: tools/ffescape.o
> >
> > CC      tools/ffescape.o
> > tools/ffescape.c: In function ‘main’:
> > tools/ffescape.c:83:59: error: expected ‘)’ before ‘escape_flags’
> >              else if (!strcmp(optarg, "xml_single_quotes") escape_flags |= AV_ESCAPE_FLAG_XML_SINGLE_QUOTES);
> >                                                            ^~~~~~~~~~~~
> > tools/ffescape.c:84:59: error: expected ‘)’ before ‘escape_flags’
> >              else if (!strcmp(optarg, "xml_double_quotes") escape_flags |= AV_ESCAPE_FLAG_XML_DOUBLE_QUOTES);
> >                                                            ^~~~~~~~~~~~
> > ffbuild/common.mak:67: recipe for target 'tools/ffescape.o' failed
> > make: *** [tools/ffescape.o] Error 1
>
> OK, sorry. That is a clear mistake yet I somehow thought that was
> built by default and thus it was OK :/
>
> Will fix.
>

Is now fixed as:

diff --git a/tools/ffescape.c b/tools/ffescape.c
index 0530d28c6d..1ed8daa801 100644
--- a/tools/ffescape.c
+++ b/tools/ffescape.c
@@ -78,8 +78,10 @@ int main(int argc, char **argv)
             infilename = optarg;
             break;
         case 'f':
-            if      (!strcmp(optarg, "whitespace")) escape_flags |=
AV_ESCAPE_FLAG_WHITESPACE;
-            else if (!strcmp(optarg, "strict"))     escape_flags |=
AV_ESCAPE_FLAG_STRICT;
+            if      (!strcmp(optarg, "whitespace"))
escape_flags |= AV_ESCAPE_FLAG_WHITESPACE;
+            else if (!strcmp(optarg, "strict"))
escape_flags |= AV_ESCAPE_FLAG_STRICT;
+            else if (!strcmp(optarg, "xml_single_quotes"))
escape_flags |= AV_ESCAPE_FLAG_XML_SINGLE_QUOTES;
+            else if (!strcmp(optarg, "xml_double_quotes"))
escape_flags |= AV_ESCAPE_FLAG_XML_DOUBLE_QUOTES;
             else {
                 av_log(NULL, AV_LOG_ERROR,
                        "Invalid value '%s' for option -f, "
@@ -104,6 +106,7 @@ int main(int argc, char **argv)
             if      (!strcmp(optarg, "auto"))      escape_mode =
AV_ESCAPE_MODE_AUTO;
             else if (!strcmp(optarg, "backslash")) escape_mode =
AV_ESCAPE_MODE_BACKSLASH;
             else if (!strcmp(optarg, "quote"))     escape_mode =
AV_ESCAPE_MODE_QUOTE;
+            else if (!strcmp(optarg, "xml"))       escape_mode =
AV_ESCAPE_MODE_XML;
             else {
                 av_log(NULL, AV_LOG_ERROR,
                        "Invalid value '%s' for option -m, "


More information about the ffmpeg-devel mailing list