Skip to content

Commit 914791e

Browse files
committed
bounce: fix MDN-part-2 body being erroneously joined to MDN-part-2 header
Fixes: gromox-2.24-74-gf43cff201 References: GXL-433
1 parent 6dbdeb3 commit 914791e

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

exch/bounce_exch.cpp

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// SPDX-License-Identifier: GPL-2.0-only WITH linking exception
2-
// SPDX-FileCopyrightText: 2021-2024 grommunio GmbH
2+
// SPDX-FileCopyrightText: 2021–2025 grommunio GmbH
33
// This file is part of Gromox.
44
#include <ctime>
55
#include <string>
@@ -12,6 +12,7 @@
1212
#include <vmime/dateTime.hpp>
1313
#include <vmime/mailbox.hpp>
1414
#include <vmime/stringContentHandler.hpp>
15+
#include <vmime/utility/outputStreamAdapter.hpp>
1516
#include <gromox/bounce_gen.hpp>
1617
#include <gromox/element_data.hpp>
1718
#include <gromox/rop_util.hpp>
@@ -133,19 +134,24 @@ bool exch_bouncer_make(buff_t gudn, meta_t meta,
133134
pmail->getBody()->appendPart(std::move(part1));
134135

135136
auto part2 = vmime::make_shared<vmime::bodyPart>();
136-
auto dsn = part2->getHeader();
137-
dsn->getField("Final-Recipient")->setValue("rfc822;"s + username);
137+
vmime::header dsn;
138+
dsn.getField("Final-Recipient")->setValue("rfc822;"s + username);
138139
if (strcmp(bounce_type, "BOUNCE_NOTIFY_READ") == 0)
139-
dsn->getField("Disposition")->setValue("automatic-action/MDN-sent-automatically; displayed");
140+
dsn.getField("Disposition")->setValue("automatic-action/MDN-sent-automatically; displayed");
140141
else if (strcmp(bounce_type, "BOUNCE_NOTIFY_NON_READ") == 0)
141-
dsn->getField("Disposition")->setValue("manual-action/MDN-sent-automatically; deleted");
142+
dsn.getField("Disposition")->setValue("manual-action/MDN-sent-automatically; deleted");
142143
str = pbrief->proplist.get<char>(PR_INTERNET_MESSAGE_ID);
143144
if (str != nullptr)
144-
dsn->getField("Original-Message-ID")->setValue(str);
145+
dsn.getField("Original-Message-ID")->setValue(str);
145146
bv = pbrief->proplist.get<BINARY>(PR_PARENT_KEY);
146147
if (bv != nullptr)
147-
dsn->getField("X-MSExch-Correlation-Key")->setValue(base64_encode({bv->pc, bv->cb}));
148-
dsn->getField("X-Display-Name")->setValue(expeditor);
148+
dsn.getField("X-MSExch-Correlation-Key")->setValue(base64_encode({bv->pc, bv->cb}));
149+
dsn.getField("X-Display-Name")->setValue(expeditor);
150+
151+
std::ostringstream oss;
152+
vmime::utility::outputStreamAdapter vos(oss);
153+
dsn.generate(vos);
154+
part2->getBody()->setContents(vmime::make_shared<vmime::stringContentHandler>(oss.str()));
149155
part2->getBody()->setContentType(vmime::mediaType(vmime::mediaTypes::MESSAGE, vmime::mediaTypes::MESSAGE_DISPOSITION_NOTIFICATION));
150156
pmail->getBody()->appendPart(std::move(part2));
151157
return true;

0 commit comments

Comments
 (0)