Send the osTicket ticket text raw after the data: prefix, with no encoding
Percent-encoding put "%20" in every space of a real ticket, and the base64 that replaced it arrived as base64. osTicket (Format::parseRfc2397, via ApiJsonDataParser::fixup) takes the message's type from the "data:" prefix and uses everything after the first comma exactly as it is, decoding nothing; its own documented example is plain text after the comma. The text is now sent raw (JSON takes care of quotes and line breaks; later commas are fine, since only the first one splits). The test now mimics that parsing -- split at the first comma, decode nothing -- and requires the text to arrive exactly as written; it fails if percent-encoding or base64 comes back. The stand-in server in the earlier test had decoded the encoding, which is why neither mistake was caught. INTEGRATIONS.md says what happened and that it hasn't been re-checked against a real osTicket. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
5072cee519
commit
5386c1abe7
3 files changed
+15
-12
No files matched your search
@@ -229,11 +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. 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 — åäö ✓");
|
||||
// What osTicket does with the message (include/class.format.php, parseRfc2397): split at the FIRST comma, use the rest as it is.
|
||||
// It applies no decoding, so any encoding here shows up in the ticket — percent-encoding as "%20", base64 as base64.
|
||||
const comma = s.body.message.indexOf(",");
|
||||
assert.equal(s.body.message.slice(0, comma + 1), "data:text/plain;charset=utf-8,");
|
||||
assert.equal(s.body.message.slice(comma + 1), "Line one\nLine two — åäö ✓", "the text must reach osTicket exactly as written");
|
||||
});
|
||||
|
||||
test("topic and priority are sent only when set; staff alerts can be switched off", async () => {
|
||||
|
||||
Reference in new issue
Block a user