summaryrefslogtreecommitdiffstats
path: root/libmenu
diff options
context:
space:
mode:
authoralbeu <albeu@b3059339-0415-0410-9bf9-f77b7e298cf2>2003-08-15 18:45:35 +0000
committeralbeu <albeu@b3059339-0415-0410-9bf9-f77b7e298cf2>2003-08-15 18:45:35 +0000
commit38a2fa46fd084eb21a3b348e6f73fabd5d992edc (patch)
tree95aacde47bb2eabad7b1305c56e1deb46e1df9de /libmenu
parent9646f76179ad4536d0c631353f02f2d86929bc4d (diff)
downloadmpv-38a2fa46fd084eb21a3b348e6f73fabd5d992edc.tar.bz2
mpv-38a2fa46fd084eb21a3b348e6f73fabd5d992edc.tar.xz
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 git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@10625 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'libmenu')
-rw-r--r--libmenu/menu_filesel.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/libmenu/menu_filesel.c b/libmenu/menu_filesel.c
index e7835773b6..4dd2d69e8b 100644
--- a/libmenu/menu_filesel.c
+++ b/libmenu/menu_filesel.c
@@ -77,12 +77,22 @@ static char* replace_path(char* title , char* dir) {
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;