]> git.sesse.net Git - vlc/commitdiff
Replace forbidden characters with underscores when attempting to dump a stream (close...
authorRémi Denis-Courmont <rem@videolan.org>
Mon, 13 Feb 2006 19:14:30 +0000 (19:14 +0000)
committerRémi Denis-Courmont <rem@videolan.org>
Mon, 13 Feb 2006 19:14:30 +0000 (19:14 +0000)
modules/access_filter/record.c

index a87dedd4a00274679e758fb9e9db55ba44dfea98..b0176b7d16c05f9d99913c4610dfb4a8e2c3a827 100644 (file)
@@ -1,7 +1,7 @@
 /*****************************************************************************
  * record.c
  *****************************************************************************
- * Copyright (C) 2005 the VideoLAN team
+ * Copyright (C) 2005-2006 the VideoLAN team
  * $Id$
  *
  * Author: Laurent Aimar <fenrir@via.ecp.fr>
@@ -357,7 +357,7 @@ static void Dump( access_t *p_access, uint8_t *p_buffer, int i_buffer )
     if( !p_sys->f )
     {
         input_thread_t *p_input;
-        char *psz_name = NULL;
+        char *psz_name = NULL, *psz;
         time_t t = time(NULL);
         struct tm l;
 
@@ -403,6 +403,23 @@ static void Dump( access_t *p_access, uint8_t *p_buffer, int i_buffer )
 
         free( psz_name );
 
+        /* Remove all forbidden characters (except (back)slashes) */
+        for( psz = p_sys->psz_file; *psz; psz++ )
+        {
+            unsigned char c = (unsigned char)*psz;
+
+            /* Even if many OS accept non printable characters, we remove
+             * them to avoid confusing users */
+            if( ( c < 32 ) || ( c == 127 ) )
+                *psz = '_';
+#if defined (WIN32) || defined (UNDER_CE)
+            /* Windows has a lot of forbidden characters, even if it has
+             * fewer than DOS. */
+            if( strchr( "\"*:<>?|", c ) != NULL )
+                *psz = '_';
+#endif
+        }
+
         msg_Dbg( p_access, "dump in file '%s'", p_sys->psz_file );
 
         p_sys->f = utf8_fopen( p_sys->psz_file, "wb" );