[Mplayer-cvslog] CVS: main/libmenu menu_filesel.c,1.9,1.10

Alban Bedel CVS albeu at mplayerhq.hu
Fri Aug 15 20:45:49 CEST 2003


Update of /cvsroot/mplayer/main/libmenu
In directory mail:/var/tmp.root/cvs-serv10913/libmenu

Modified Files:
	menu_filesel.c 
Log Message:
I've juste found a bug which prevent to load a file whose name contain
a quote ('). The menu simply execute a "loadfile '%p'" but when the %p
is replaced by the actual value, quotes in it are not escaped !
Moreover, mp_input_parse_cmd contain some code to unescape strings but
this code was placed after the string was copied in his final buffer.

So this patch correct this issue.

By Aurélien Jacobs


Index: menu_filesel.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmenu/menu_filesel.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- menu_filesel.c	9 Feb 2003 20:18:20 -0000	1.9
+++ menu_filesel.c	15 Aug 2003 18:45:35 -0000	1.10
@@ -77,12 +77,22 @@
     int dl = strlen(dir);
     int t1l = p-title; 
     int l = tl - 2 + dl;
-    char*r = malloc(l + 1);
+    char *r, *n, *d = dir;
+    char term = *(p-1);
+
+    do {
+      if (*d == '\\' || *d == term)
+        l++;
+    } while (*d++);
+    r = malloc(l + 1);
+    n = r + t1l;
     memcpy(r,title,t1l);
-    memcpy(r+t1l,dir,dl);
+    do {
+      if (*dir == '\\' || *dir == term)
+        *n++ = '\\';
+    } while ((*n++ = *dir++));
     if(tl - t1l - 2 > 0)
-      memcpy(r+t1l+dl,p+2,tl - t1l - 2);
-    r[l] = '\0';
+      strcpy(n-1,p+2);
     return r;
   } else
     return title;



More information about the MPlayer-cvslog mailing list