Don't include empty root folder path segment constructing a mailbox name
This fixes attempts to create special mailboxes as "/Special" instead of "Special".
This commit is contained in:
parent
94809971ee
commit
3e461e7b45
2 changed files with 59 additions and 0 deletions
|
|
@ -127,6 +127,12 @@ public class Geary.Imap.MailboxSpecifier : BaseObject, Gee.Hashable<MailboxSpeci
|
|||
throw new ImapError.INVALID("Path has more than one part but no delimiter given");
|
||||
}
|
||||
|
||||
// Don't include the root if it is an empty string so that
|
||||
// mailboxes do not begin with the delim.
|
||||
if (parts.size > 1 && parts[0] == "") {
|
||||
parts.remove_at(0);
|
||||
}
|
||||
|
||||
StringBuilder builder = new StringBuilder(
|
||||
is_inbox_name(parts[0]) ? inbox.name : parts[0]);
|
||||
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ class Geary.Imap.MailboxSpecifierTest : TestCase {
|
|||
base("Geary.Imap.MailboxSpecifierTest");
|
||||
add_test("to_parameter", to_parameter);
|
||||
add_test("from_parameter", from_parameter);
|
||||
add_test("from_folder_path", from_folder_path);
|
||||
}
|
||||
|
||||
public void to_parameter() throws Error {
|
||||
|
|
@ -57,4 +58,56 @@ class Geary.Imap.MailboxSpecifierTest : TestCase {
|
|||
);
|
||||
}
|
||||
|
||||
public void from_folder_path() throws Error {
|
||||
MockFolderRoot empty_root = new MockFolderRoot("");
|
||||
MailboxSpecifier empty_inbox = new MailboxSpecifier("Inbox");
|
||||
assert_string(
|
||||
"Foo",
|
||||
new MailboxSpecifier.from_folder_path(
|
||||
empty_root.get_child("Foo"), empty_inbox, "$"
|
||||
).name
|
||||
);
|
||||
assert_string(
|
||||
"Foo$Bar",
|
||||
new MailboxSpecifier.from_folder_path(
|
||||
empty_root.get_child("Foo").get_child("Bar"), empty_inbox, "$"
|
||||
).name
|
||||
);
|
||||
assert_string(
|
||||
"Inbox",
|
||||
new MailboxSpecifier.from_folder_path(
|
||||
empty_root.get_child(MailboxSpecifier.CANONICAL_INBOX_NAME),
|
||||
empty_inbox,
|
||||
"$"
|
||||
).name
|
||||
);
|
||||
|
||||
MockFolderRoot non_empty_root = new MockFolderRoot("Root");
|
||||
MailboxSpecifier non_empty_inbox = new MailboxSpecifier("Inbox");
|
||||
assert_string(
|
||||
"Root$Foo",
|
||||
new MailboxSpecifier.from_folder_path(
|
||||
non_empty_root.get_child("Foo"),
|
||||
non_empty_inbox,
|
||||
"$"
|
||||
).name
|
||||
);
|
||||
assert_string(
|
||||
"Root$Foo$Bar",
|
||||
new MailboxSpecifier.from_folder_path(
|
||||
non_empty_root.get_child("Foo").get_child("Bar"),
|
||||
non_empty_inbox,
|
||||
"$"
|
||||
).name
|
||||
);
|
||||
assert_string(
|
||||
"Root$INBOX",
|
||||
new MailboxSpecifier.from_folder_path(
|
||||
non_empty_root.get_child(MailboxSpecifier.CANONICAL_INBOX_NAME),
|
||||
non_empty_inbox,
|
||||
"$"
|
||||
).name
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue