[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

[TSVN] Improper quoting when running external diff/merge?

From: Brian Wong <bdwong-net_at_shaw.ca>
Date: 2005-03-03 07:27:48 CET

Hi,

I have some odd quoting behavior to report.

I am writing a simple external diff program for .doc files in C++. I
added the .doc file extension under the Advanced Diff settings. For the
command line I type:

    C:\bin\externaldiff.exe %base %mine

When externaldiff.exe is run, I call GetCommandLineW() to get the
command line in Unicode. When TortoiseSVN diffs files file1.doc and
file2.doc, I expect to get this string back:

    "C:\bin\externaldiff.exe" "C:\path\file1.doc" "C:\path\file2.doc"

Instead I get the following string (note the "missing" quote):

    "C:\bin\externaldiff.exe "C:\path\file1.doc" "C:\path\file2.doc"

I would expect the former string because it is easy to parse, while the
latter is not. Running externaldiff.exe from the command line does not
quote the executable unless I quote it manually. This happens in
TortoiseSVN 1.1.3. TortoiseSVN 1.1.2 doesn't use %base and %mine.

The offending code seems to be in /trunk/src/TortoiseProc/Utils.cpp in
CUtils::StartExtDiff() (and similar code in CUtils::StartExtMerge()) as
follows:

        // is there an extension specific diff tool?
        CRegString difftool(_T("Software\\TortoiseSVN\\DiffTools\\") +
file2.GetFileExtension().MakeLower());
        if (CString(difftool) != "")
        {
                viewer = difftool;
                viewer = _T("\"") + viewer + _T("\"");
        }

If I'm reading this right, it reads the registry key which contains
"C:\bin\externaldiff.exe %base %mine", then it quotes the entire string.
However it looks like it should be quoting only the executable.

If I may suggest a fix, either:
    * Separate the program name and parameters into separate fields, OR
    * Don't quote the string.

Thank you for your attention.
Brian Wong

Please CC replies to bdwong DASH net AT shaw DOT ca.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tortoisesvn.tigris.org
For additional commands, e-mail: dev-help@tortoisesvn.tigris.org
Received on Thu Mar 3 10:09:48 2005

This is an archived mail posted to the TortoiseSVN Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.