From 38a2fa46fd084eb21a3b348e6f73fabd5d992edc Mon Sep 17 00:00:00 2001 From: albeu Date: Fri, 15 Aug 2003 18:45:35 +0000 Subject: 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. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- libmenu/menu_filesel.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'libmenu') 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; -- cgit v1.2.3