Bug 392729 - Links for nntp and news Protocols Ignored or crash [@ nsNntpService::MessageURIToMsgHdr(char const*, nsIMsgDBHdr**) ]. r=bienvenu+jcranmer

This commit is contained in:
Makoto Kato 2010-12-06 14:16:46 +09:00
Родитель 0d050a16b2
Коммит db70852b9c
2 изменённых файлов: 48 добавлений и 7 удалений

Просмотреть файл

@ -596,8 +596,8 @@ nsNntpService::DecomposeNewsMessageURI(const char * aMessageURI, nsIMsgFolder **
keyStr = Substring(newsUrl, keyPos + kNewsURIKeyQueryLen);
// get message key
nsMsgKey key = nsMsgKey_None;
nsresult errorCode;
key = keyStr.ToInteger(&errorCode, 10);
key = keyStr.ToInteger(&rv, 10);
NS_ENSURE_SUCCESS(rv,rv);
// get userPass
nsCAutoString userPass;
@ -632,11 +632,8 @@ nsNntpService::DecomposeNewsMessageURI(const char * aMessageURI, nsIMsgFolder **
getter_AddRefs(child));
NS_ENSURE_SUCCESS(rv,rv);
if (!errorCode)
{
child.swap(*aFolder);
*aMsgKey = key;
}
child.swap(*aFolder);
*aMsgKey = key;
}
else
{
@ -645,6 +642,11 @@ nsNntpService::DecomposeNewsMessageURI(const char * aMessageURI, nsIMsgFolder **
*aMsgKey = nsMsgKey_None;
}
}
else
{
// This schema isn't supported
return NS_ERROR_INVALID_ARG;
}
return NS_OK;
}

Просмотреть файл

@ -0,0 +1,39 @@
/* -*- Mode: JavaScript; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
*
* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/licenses/publicdomain/
*
* ***** END LICENSE BLOCK ***** */
function getMessageHeaderFromUrl(aUrl) {
let msgUrl = Cc["@mozilla.org/messenger/messageservice;1?type=news"]
.getService(Ci.nsINntpService)
.QueryInterface(Ci.nsIProtocolHandler)
.newURI(aUrl, null, null)
.QueryInterface(Ci.nsIMsgMessageUrl);
return msgUrl.messageHeader;
}
function run_test() {
// This is crash test for Bug 392729
try {
// nntp:// protocol isn't supported yet until bug 226890 is fixed.
// When We pass invlid nntp:// protocol format, we should throw a exception.
let hdr = getMessageHeaderFromUrl("nntp://localhost:" + NNTP_PORT);
do_check_true(false);
} catch (e) {
do_check_true(e.result == Components.results.NS_ERROR_ILLEGAL_VALUE);
}
try {
// msgkey is invalid for news:// protocol
let hdr = getMessageHeaderFromUrl("news://localhost:" + NNTP_PORT +
"/message-id?group=test.subscribe.simple&key=abcdefghijk");
do_check_true(false);
} catch (e) {
do_check_true(e.result == Components.results.NS_ERROR_ILLEGAL_VALUE);
}
}