зеркало из https://github.com/mozilla/pjs.git
Bug #378942 --> The compose command line handler is consuming all arguments passed in with the -url flag even if the url argument isn't a mailto looking url.
This breaks extensions (like Bob's Spider extension) that implement command line handlers that use the -url flag. sr=bienvenu
This commit is contained in:
Родитель
763a69ab7b
Коммит
bcc27437ee
|
@ -1497,6 +1497,7 @@ nsMsgComposeService::Handle(nsICommandLine* aCmdLine)
|
|||
nsresult rv;
|
||||
PRInt32 found, end, count;
|
||||
nsAutoString uristr;
|
||||
PRBool composeShouldHandle = PR_TRUE;
|
||||
|
||||
rv = aCmdLine->FindFlag(NS_LITERAL_STRING("compose"), PR_FALSE, &found);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
@ -1505,7 +1506,12 @@ nsMsgComposeService::Handle(nsICommandLine* aCmdLine)
|
|||
// MAC OS X passes in -url mailto:mscott@mozilla.org into the command line
|
||||
// instead of -compose.
|
||||
if (found == -1)
|
||||
{
|
||||
rv = aCmdLine->FindFlag(NS_LITERAL_STRING("url"), PR_FALSE, &found);
|
||||
// we don't want to consume the argument for -url unless we're sure it is a mailto url and we'll
|
||||
// figure that out shortly.
|
||||
composeShouldHandle = PR_FALSE;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (found == -1)
|
||||
|
@ -1519,11 +1525,12 @@ nsMsgComposeService::Handle(nsICommandLine* aCmdLine)
|
|||
if (count > found + 1) {
|
||||
aCmdLine->GetArgument(found + 1, uristr);
|
||||
if (StringBeginsWith(uristr, NS_LITERAL_STRING("mailto:")) ||
|
||||
StringBeginsWith(uristr, NS_LITERAL_STRING("to=")) ||
|
||||
StringBeginsWith(uristr, NS_LITERAL_STRING("cc=")) ||
|
||||
StringBeginsWith(uristr, NS_LITERAL_STRING("subject=")) ||
|
||||
StringBeginsWith(uristr, NS_LITERAL_STRING("body=")) ||
|
||||
StringBeginsWith(uristr, NS_LITERAL_STRING("attachment="))) {
|
||||
StringBeginsWith(uristr, NS_LITERAL_STRING("to=")) ||
|
||||
StringBeginsWith(uristr, NS_LITERAL_STRING("cc=")) ||
|
||||
StringBeginsWith(uristr, NS_LITERAL_STRING("subject=")) ||
|
||||
StringBeginsWith(uristr, NS_LITERAL_STRING("body=")) ||
|
||||
StringBeginsWith(uristr, NS_LITERAL_STRING("attachment="))) {
|
||||
composeShouldHandle = PR_TRUE; // the -url argument looks like mailto
|
||||
end++;
|
||||
// mailto: URIs are frequently passed with spaces in them. They should be
|
||||
// escaped with %20, but we hack around broken clients. See bug 231032.
|
||||
|
@ -1542,24 +1549,26 @@ nsMsgComposeService::Handle(nsICommandLine* aCmdLine)
|
|||
uristr.Truncate();
|
||||
}
|
||||
}
|
||||
if (composeShouldHandle)
|
||||
{
|
||||
aCmdLine->RemoveArguments(found, end);
|
||||
|
||||
aCmdLine->RemoveArguments(found, end);
|
||||
nsCOMPtr<nsIWindowWatcher> wwatch (do_GetService(NS_WINDOWWATCHER_CONTRACTID));
|
||||
NS_ENSURE_TRUE(wwatch, NS_ERROR_FAILURE);
|
||||
|
||||
nsCOMPtr<nsIWindowWatcher> wwatch (do_GetService(NS_WINDOWWATCHER_CONTRACTID));
|
||||
NS_ENSURE_TRUE(wwatch, NS_ERROR_FAILURE);
|
||||
nsCOMPtr<nsISupportsString> arg;
|
||||
if (!uristr.IsEmpty()) {
|
||||
arg = do_CreateInstance(NS_SUPPORTS_STRING_CONTRACTID);
|
||||
if (arg)
|
||||
arg->SetData(uristr);
|
||||
}
|
||||
|
||||
nsCOMPtr<nsISupportsString> arg;
|
||||
if (!uristr.IsEmpty()) {
|
||||
arg = do_CreateInstance(NS_SUPPORTS_STRING_CONTRACTID);
|
||||
if (arg)
|
||||
arg->SetData(uristr);
|
||||
}
|
||||
nsCOMPtr<nsIDOMWindow> opened;
|
||||
wwatch->OpenWindow(nsnull, DEFAULT_CHROME, "_blank",
|
||||
"chrome,dialog=no,all", arg, getter_AddRefs(opened));
|
||||
|
||||
nsCOMPtr<nsIDOMWindow> opened;
|
||||
wwatch->OpenWindow(nsnull, DEFAULT_CHROME, "_blank",
|
||||
"chrome,dialog=no,all", arg, getter_AddRefs(opened));
|
||||
|
||||
aCmdLine->SetPreventDefault(PR_TRUE);
|
||||
aCmdLine->SetPreventDefault(PR_TRUE);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче