Bug 761069: B2G MMS: support email addressing model, r=philikon

This commit is contained in:
Vicamo Yang 2012-07-26 10:07:56 +08:00
parent 2d4d4c363f
commit ccc3866d3c
2 changed files with 11 additions and 3 deletions

View File

@ -92,8 +92,13 @@ let Address = {
type = "num";
} else if (str.match(/^\w+$/)) {
type = "alphanum";
} else if (str.indexOf("@") > 0) {
// E-mail should match the definition of `mailbox` as described in section
// 3.4 of RFC2822, but excluding the obsolete definitions as indicated by
// the "obs-" prefix. Here we match only a `@` character.
type = "email";
} else {
type = "unknown";
throw new WSP.CodeError("Address: invalid address");
}
return {address: str, type: type};

View File

@ -71,9 +71,12 @@ add_test(function test_Address_decode() {
// Test for alphanum-shortcode
wsp_decode_test(MMS.Address, strToCharCodeArray("H0wD0Y0uTurnTh1s0n"),
{address: "H0wD0Y0uTurnTh1s0n", type: "alphanum"});
// Test for other unknown typed sequence
// Test for email address
wsp_decode_test(MMS.Address, strToCharCodeArray("Joe User <joe@user.org>"),
{address: "Joe User <joe@user.org>", type: "unknown"});
{address: "Joe User <joe@user.org>", type: "email"});
// Test for invalid address
wsp_decode_test(MMS.Address, strToCharCodeArray("@@@@@"),
null, "CodeError");
run_next_test();
});