From 267ab9ada98375844ba4bbda4da2cf11f5402e59 Mon Sep 17 00:00:00 2001 From: "scott%scott-macgregor.org" Date: Tue, 21 Dec 2004 00:06:10 +0000 Subject: [PATCH] Bug #231032 --> mailto: tag does not work with unescaped spaces (e.g., in subject) port aviary 1.0 fix to the trunk sr=bienvenu git-svn-id: svn://10.0.0.236/trunk@166903 18797224-902f-48f8-a5cc-f745e15eee43 --- .../startup/src/nsCommandLineService.cpp | 32 +++++++++++++++---- 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/mozilla/toolkit/components/startup/src/nsCommandLineService.cpp b/mozilla/toolkit/components/startup/src/nsCommandLineService.cpp index 1c293ecc4ab..8b7b9d67dab 100644 --- a/mozilla/toolkit/components/startup/src/nsCommandLineService.cpp +++ b/mozilla/toolkit/components/startup/src/nsCommandLineService.cpp @@ -159,15 +159,35 @@ nsCmdLineService::Initialize(int aArgc, char ** aArgv) continue; } else { + + // if this argument begins with mailto: then it needs to incorporate all subsequent arguments + // that come after it since mailto urls can have arbitrary unencoded spaces + if (!nsCRT::strncasecmp(aArgv[i], "mailto:", 7)) { + nsCAutoString mailtoUrl; + + mailtoUrl += aArgv[i++]; + + for (; i < aArgc; i++) + { + mailtoUrl += " "; // we have to put the spaces separating the arguments back + mailtoUrl += aArgv[i]; + } + + mArgValueList.AppendElement(NS_REINTERPRET_CAST(void*, ToNewCString(mailtoUrl))); + mArgCount++; + + // i should now == aArgc so we should naturally fall out of our outer for loop + + } else if (i == (aArgc-1)) { /* The next argument does not start with '-'. This * could be value to the previous option */ - if (i == (aArgc-1)) { - /* This is the last argument and a URL - * Append a PR_TRUE for the previous option in the value array - */ - mArgValueList.AppendElement(ProcessURLArg(aArgv[i])); - mArgCount++; + + /* This is the last argument and a URL + * Append a PR_TRUE for the previous option in the value array + */ + mArgValueList.AppendElement(ProcessURLArg(aArgv[i])); + mArgCount++; continue; } else {