[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#120152: Patch: sdiff support



On Sat, Nov 15, 2003 at 08:52:52PM +0100, Josip Rodin wrote:
> On Sat, Nov 15, 2003 at 07:05:04PM +0200, Jarno Elonen wrote:
> >  * Enclosed file names with quotes in command string (Closes #147583)
> 
> Umm...
> 
> @@ -450,7 +450,7 @@
>                 if (!p || !*p)
>                         p=DEFAULTPAGER;
> 
> -               sprintf(cmdbuf, DIFF " -Nu %.250s %.250s | %.250s", old, new, p);
> +               sprintf(cmdbuf, DIFF " -N \"%.250s\" \"%.250s\" | %.250s", old, new, p);
> 
>                 s=getenv(SHELLENV);
>                 if (!s || !*s)

That looks like a bad idea anyway; what if the filename contains ", $,
or `?

In general adding more levels of quotation is the wrong way to fix this
kind of bug, as you can never win. Instead, forget about the quotes and
simply backslash-escape non-word characters. The algorithm described in
'perldoc -f quotemeta' will do the job.

Cheers,

-- 
Colin Watson                                  [cjwatson@flatline.org.uk]



Reply to: