Damjan Jovanovic : start.exe: Unquote the title.

Alexandre Julliard julliard at winehq.org
Mon Aug 19 15:35:12 CDT 2019


Module: wine
Branch: master
Commit: 6ae919de8112483c3e4c1b0cd69e0de6f084d038
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=6ae919de8112483c3e4c1b0cd69e0de6f084d038

Author: Damjan Jovanovic <damjan.jov at gmail.com>
Date:   Sun Aug 11 16:28:26 2019 +0200

start.exe: Unquote the title.

Signed-off-by: Damjan Jovanovic <damjan.jov at gmail.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 programs/start/start.c | 30 +++++++++++++++++++++++++++++-
 1 file changed, 29 insertions(+), 1 deletion(-)

diff --git a/programs/start/start.c b/programs/start/start.c
index 18fd5f5..1bdcba9 100644
--- a/programs/start/start.c
+++ b/programs/start/start.c
@@ -172,6 +172,25 @@ static BOOL is_option(const WCHAR* arg, const WCHAR* opt)
                           arg, -1, opt, -1) == CSTR_EQUAL;
 }
 
+static void parse_title(const WCHAR *arg, WCHAR *title, int size)
+{
+    /* See:
+     *     WCMD_start() in programs/cmd/builtins.c
+     *     WCMD_parameter_with_delims() in programs/cmd/batch.c
+     * The shell has already tokenized the command line for us.
+     * All we need to do is filter out all the quotes.
+     */
+
+    int next;
+    const WCHAR *p = arg;
+
+    for (next = 0; next < (size-1) && *p; p++) {
+        if (*p != '"')
+            title[next++] = *p;
+    }
+    title[next] = '\0';
+}
+
 int wmain (int argc, WCHAR *argv[])
 {
 	SHELLEXECUTEINFOW sei;
@@ -223,7 +242,15 @@ int wmain (int argc, WCHAR *argv[])
 	for (i=1; i<argc; i++) {
                 /* parse first quoted argument as console title */
                 if (!title && argv[i][0] == '"') {
-			title = argv[i];
+			/* it will remove at least 1 quote */
+			int maxChars = lstrlenW(argv[1]);
+			title = HeapAlloc(GetProcessHeap(), 0, maxChars*sizeof(WCHAR));
+			if (title)
+				parse_title(argv[i], title, maxChars);
+			else {
+				WINE_ERR("out of memory\n");
+				ExitProcess(1);
+			}
 			continue;
 		}
 		if (argv[i][0] != '/')
@@ -457,6 +484,7 @@ done:
 	HeapFree( GetProcessHeap(), 0, args );
 	HeapFree( GetProcessHeap(), 0, dos_filename );
 	HeapFree( GetProcessHeap(), 0, parent_directory );
+	HeapFree( GetProcessHeap(), 0, title );
 
 	if (sei.fMask & SEE_MASK_NOCLOSEPROCESS) {
 		DWORD exitcode;




More information about the wine-cvs mailing list