Skip to content

Commit b7b8d77

Browse files
committed
oxcmail: let oxcmail_export_reply_to recognize EMSAB entryids
Referring to EX entities is generally done with EMSAB_ENTRYID, not ONEOFF_ENTRYIDs. References: GXL-245
1 parent cfd2940 commit b7b8d77

File tree

1 file changed

+32
-18
lines changed

1 file changed

+32
-18
lines changed

lib/mapi/oxcmail.cpp

Lines changed: 32 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2922,6 +2922,31 @@ static BOOL oxcmail_export_addresses(const TARRAY_SET &rcpt_list,
29222922
return false;
29232923
}
29242924

2925+
static bool genentryid_to_smtpaddr(const BINARY &bin, std::string &dispname,
2926+
std::string &emaddr)
2927+
{
2928+
EXT_PULL ep;
2929+
EMSAB_ENTRYID ems;
2930+
ep.init(bin.pb, bin.cb, malloc, EXT_FLAG_UTF16);
2931+
if (ep.g_abk_eid(&ems) == pack_result::ok &&
2932+
cvt_essdn_to_username(ems.x500dn.c_str(), g_oxcmail_org_name,
2933+
oxcmail_get_username, emaddr) == ecSuccess)
2934+
return true;
2935+
2936+
ONEOFF_ENTRYID oo;
2937+
ep.init(bin.pb, bin.cb, malloc, EXT_FLAG_UTF16);
2938+
if (ep.g_oneoff_eid(&oo) == pack_result::ok) {
2939+
dispname = std::move(oo.pdisplay_name);
2940+
if (cvt_genaddr_to_smtpaddr(oo.paddress_type.c_str(),
2941+
oo.pmail_address.c_str(), g_oxcmail_org_name,
2942+
oxcmail_get_username, emaddr) == ecSuccess)
2943+
return true;
2944+
}
2945+
2946+
mlog(LV_WARN, "W-1964: skipping unrecognizable entry in PR_REPLY_RECIPIENTS_TO");
2947+
return false;
2948+
}
2949+
29252950
static bool oxcmail_export_reply_to(const MESSAGE_CONTENT *pmsg,
29262951
vmime::addressList &adrlist) try
29272952
{
@@ -2945,26 +2970,15 @@ static bool oxcmail_export_reply_to(const MESSAGE_CONTENT *pmsg,
29452970
if (ext_pull.g_flatentry_a(&address_array) != pack_result::ok)
29462971
return FALSE;
29472972
for (size_t i = 0; i < address_array.count; ++i) {
2948-
EXT_PULL ep2;
2949-
ONEOFF_ENTRYID oo{};
2950-
ep2.init(address_array.pbin[i].pb, address_array.pbin[i].cb,
2951-
malloc, EXT_FLAG_UTF16);
2952-
if (ep2.g_oneoff_eid(&oo) != pack_result::ok) {
2953-
mlog(LV_WARN, "W-1964: skipping malformed reply-to entry");
2954-
continue;
2955-
}
2956-
std::string emaddr;
2957-
if (cvt_genaddr_to_smtpaddr(oo.paddress_type.c_str(),
2958-
oo.pmail_address.c_str(), g_oxcmail_org_name,
2959-
oxcmail_get_username, emaddr) != ecSuccess) {
2960-
mlog(LV_WARN, "W-1964: skipping %s reply-to entry", oo.paddress_type.c_str());
2973+
std::string dispname, emaddr;
2974+
if (!genentryid_to_smtpaddr(address_array.pbin[i], dispname, emaddr))
29612975
continue;
2962-
}
29632976
auto mb = vmime::make_shared<vmime::mailbox>("");
2964-
if (!oo.pdisplay_name.empty())
2965-
mb->setName(vmime::text(std::move(oo.pdisplay_name), vmime::charsets::UTF_8));
2966-
if (!oo.pmail_address.empty())
2967-
mb->setEmail(std::move(oo.pmail_address));
2977+
if (!emaddr.empty()) {
2978+
mb->setEmail(std::move(emaddr));
2979+
if (!dispname.empty())
2980+
mb->setName(vmime::text(std::move(dispname), vmime::charsets::UTF_8));
2981+
}
29682982
adrlist.appendAddress(mb);
29692983
}
29702984
return true;

0 commit comments

Comments
 (0)