Skip to content

Commit

Permalink
fix: marketo bulk upload handle special chars (#3859)
Browse files Browse the repository at this point in the history
  • Loading branch information
utsabc authored Nov 11, 2024
1 parent bfd7edc commit f959a7d
Show file tree
Hide file tree
Showing 2 changed files with 96 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/v0/destinations/marketo_bulk_upload/transform.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,16 @@ function responseBuilderSimple(message, destination) {
Object.keys(fieldHashmap).forEach((key) => {
const val = traits[fieldHashmap[key]];
if (isDefined(val)) {
payload[key] = val;
let newVal = val;
// If value contains comma or newline then we need to escape it
if (typeof val === 'string') {
newVal = val
.toString()
.replaceAll(/\\/g, '\\\\')
.replaceAll(/,/g, '\\,')
.replaceAll(/\n/g, '\\n');
}
payload[key] = newVal;
}
});
const response = defaultRequestConfig();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -595,4 +595,90 @@ export const data = [
},
},
},
{
name: 'marketo_bulk_upload',
description: 'Test 6: Any comma or new line should be escaped through transform payload',
feature: 'processor',
module: 'destination',
version: 'v0',
input: {
request: {
body: [
{
message: {
type: 'identify',
userId: 'nicholas003',
anonymousId: 'anonId_003',
context: {
traits: {
firstName: 'Test',
lastName: 'hello\\world,new\nline',
email: 'badRecord.email.com',
city: '776 Elm St.\nRt. ,101',
},
},
request_ip: '192.168.10.106',
},
destination: {
ID: '1mMy5cqbtfuaKZv1IhVQKnBdVwe',
Config: {
munchkinId: 'XXXX',
clientId: 'YYYY',
clientSecret: 'ZZZZ',
columnFieldsMapping: [
{
to: 'firstName',
from: 'firstName',
},
{
to: 'lastName',
from: 'lastName',
},
{
to: 'email',
from: 'email',
},
{
to: 'city',
from: 'city',
},
],
},
},
},
],
},
},
output: {
response: {
status: 200,
body: [
{
output: {
version: '1',
type: 'REST',
method: 'POST',
endpoint: '/fileUpload',
headers: {},
params: {},
body: {
JSON: {
firstName: 'Test',
lastName: 'hello\\\\world\\,new\\nline',
email: 'badRecord.email.com',
city: '776 Elm St.\\nRt. \\,101',
},
JSON_ARRAY: {},
XML: {},
FORM: {},
},
files: {},
userId: '',
},
statusCode: 200,
},
],
},
},
},
];

0 comments on commit f959a7d

Please sign in to comment.