[FFmpeg-devel] [PATCH] lavf/segment: add CVS escaping for CSV list file filename field

Stefano Sabatini stefasab at gmail.com
Sun Sep 2 14:34:47 CEST 2012


On date Sunday 2012-09-02 11:12:53 +0200, Clément Bœsch encoded:
> On Sat, Sep 01, 2012 at 04:15:50PM +0200, Stefano Sabatini wrote:
[...]
> > +static void avio_print_csv_escaped_str(AVIOContext *ctx, const char *str)
> > +{
> > +    const char *p;
> > +    int quote = 0;
> > +
> > +    /* check if input needs quoting */
> > +    for (p = str; *p; p++)
> > +        if (*p == '"' || *p == ',' || *p == '\n' || *p == '\r')
> > +            quote = 1;
> 
> I guess you can break when you find one. BTW, you can use something like
> "if (strchr("\",\n\r", *p)"

Changed locally that way.
 
> > +
> > +    if (quote)
> > +        avio_w8(ctx, '"');
> > +
> > +    for (p = str; *p; p++) {
> > +        if (*p == '"')
> > +            avio_w8(ctx, '"');
> 
> avio_w8(ctx, '\\') no?

No:
"silly" string, ins't it?
=>
"""silly"" string, isn't it?"
 
> [...]
> 
> No factoring planed with ffprobe btw?

See my next reply.
-- 
FFmpeg = Fast Foolish Moronic Plastic Exciting God


More information about the ffmpeg-devel mailing list