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
@@ -106,9 +106,11 @@ export function createOsTicketTicketApi(config: OsTicketApiConfig) {
|
||||
name: ticket.name,
|
||||
email: ticket.email,
|
||||
subject: ticket.subject,
|
||||
// osTicket reads the type of the message from an RFC 2397 data URL. Base64, not percent-encoding: osTicket strips the
|
||||
// "data:" part but leaves percent-encoded text as it is (a test ticket arrived full of %20), while base64 is decoded.
|
||||
message: `data:text/plain;charset=utf-8;base64,${Buffer.from(ticket.message, "utf8").toString("base64")}`,
|
||||
// osTicket takes the message's type from a "data:" prefix, and then uses everything after the FIRST comma exactly as it is:
|
||||
// it does no decoding of any kind (percent-encoded text arrived as "%20"s, base64 as base64), and its own documented example is
|
||||
// plain text after the comma. So the text goes in raw. JSON takes care of quotes and line breaks, and any further commas are
|
||||
// fine — osTicket splits at the first one only.
|
||||
message: `data:text/plain;charset=utf-8,${ticket.message}`,
|
||||
...(ticket.topicId ? { topicId: ticket.topicId } : {}),
|
||||
...(ticket.priorityId ? { priority: ticket.priorityId } : {}),
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user