Ticket #1181: 0001-filter-ctrl-chars-on-dump.patch

File 0001-filter-ctrl-chars-on-dump.patch, 1.4 KB (added by vogelchr, 4 years ago)

Patch to filter control-chars from metadata dumps.

  • libavformat/utils.c

    From 1160c79015273ee850eb0a350d77480baef2fa52 Mon Sep 17 00:00:00 2001
    From: Christian Vogel <vogelchr@vogel.cx>
    Date: Mon, 9 Apr 2012 21:03:01 +0200
    Subject: [PATCH] filter ctrl chars on dump
    
    ---
     libavformat/utils.c |   13 +++++++++++++
     1 files changed, 13 insertions(+), 0 deletions(-)
    
    diff --git a/libavformat/utils.c b/libavformat/utils.c
    index ebf34de..48d52b6 100644
    a b static void print_fps(double d, const char *postfix){ 
    36233623    else                  av_log(NULL, AV_LOG_INFO, ", %1.0fk %s", d/1000, postfix); 
    36243624} 
    36253625 
     3626/* sometimes control-characters are hidden in files' metadata, make sure 
     3627 * they are not dumped to stdout, messing up the console */ 
     3628 
     3629static void dump_md_clean(char *s,int len){ 
     3630        while(len){ 
     3631                if(*s > 0 && *s < 32) 
     3632                        *s='?'; 
     3633                len--; 
     3634                s++; 
     3635        } 
     3636} 
     3637 
    36263638static void dump_metadata(void *ctx, AVDictionary *m, const char *indent) 
    36273639{ 
    36283640    if(m && !(m->count == 1 && av_dict_get(m, "language", NULL, 0))){ 
    static void dump_metadata(void *ctx, AVDictionary *m, const char *indent) 
    36373649                    char tmp[256]; 
    36383650                    size_t len = strcspn(p, "\xd\xa"); 
    36393651                    av_strlcpy(tmp, p, FFMIN(sizeof(tmp), len+1)); 
     3652                    dump_md_clean(tmp,len); 
    36403653                    av_log(ctx, AV_LOG_INFO, "%s", tmp); 
    36413654                    p += len; 
    36423655                    if (*p == 0xd) av_log(ctx, AV_LOG_INFO, " ");