Send the osTicket ticket text as base64, not percent-encoded

A test ticket sent to a real osTicket arrived with every space shown as %20. osTicket takes the
message's type from an RFC 2397 data URL and strips the "data:" part, but leaves percent-encoded text
as it is. The message is now sent as base64 (data:text/plain;charset=utf-8;base64,...), which osTicket
decodes (it is how it takes attachments), and which works whether or not a given osTicket version
decodes percent-encoding.

The stand-in osTicket in the test had decoded the percent-encoding, which is why this wasn't caught:
the test now requires base64 and fails if any percent-encoding is in the message. INTEGRATIONS.md says
the ticket API is only partly verified against a real osTicket, and what that first test showed.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
bobbanandClaude Sonnet 5.5 committed 2026-10-08 00:05:18 +02:00
1 parent aec553f122
commit 5072cee519
3 files changed
+14 -9

No files matched your search

+5 -3
View File
@@ -229,9 +229,11 @@ describe("osTicket API client", () => {
assert.equal(s.body.source, "API");
assert.equal(s.body.alert, true);
assert.equal(s.body.autorespond, false, "an acknowledgement to the app's own address would only bounce");
// osTicket reads a message's type from an RFC 2397 data URL; decoded it must be exactly what was written
assert.match(s.body.message, /^data:text\/plain;charset=utf-8,/);
assert.equal(decodeURIComponent(s.body.message.replace(/^data:text\/plain;charset=utf-8,/, "")), "Line one\nLine two — åäö ✓");
// osTicket reads a message's type from an RFC 2397 data URL. It must be base64: osTicket leaves percent-encoded text as it is,
// which put "%20" in place of every space in a real ticket.
assert.match(s.body.message, /^data:text\/plain;charset=utf-8;base64,[A-Za-z0-9+/=]+$/);
assert.doesNotMatch(s.body.message, /%[0-9A-Fa-f]{2}/, "percent-encoding ends up in the ticket as literal text");
assert.equal(Buffer.from(s.body.message.replace(/^data:text\/plain;charset=utf-8;base64,/, ""), "base64").toString("utf8"), "Line one\nLine two — åäö ✓");
});
test("topic and priority are sent only when set; staff alerts can be switched off", async () => {