diff --git a/src/diffviewer/ydiff.c b/src/diffviewer/ydiff.c index ac7b2574f..16b90df26 100644 --- a/src/diffviewer/ydiff.c +++ b/src/diffviewer/ydiff.c @@ -43,6 +43,7 @@ #include "lib/util.h" #include "lib/widget.h" #include "lib/strutil.h" +#include "lib/strescape.h" /* strutils_glob_escape() */ #ifdef HAVE_CHARSET #include "lib/charsets.h" #endif @@ -813,8 +814,15 @@ dff_execute (const char *args, const char *extra, const char *file1, const char FBUF *f; char *cmd; int code; + char *file1_esc, *file2_esc; + + /* escape potential $ to avoid shell variable substitutions in popen() */ + file1_esc = strutils_shell_escape (file1); + file2_esc = strutils_shell_escape (file2); + cmd = g_strdup_printf ("diff %s %s %s %s %s", args, extra, opt, file1_esc, file2_esc); + g_free (file1_esc); + g_free (file2_esc); - cmd = g_strdup_printf ("diff %s %s %s \"%s\" \"%s\"", args, extra, opt, file1, file2); if (cmd == NULL) return -1;