Skip to content

Commit 80ba8bd

Browse files
committed
escape characters
1 parent e21d334 commit 80ba8bd

File tree

6 files changed

+44
-13
lines changed

6 files changed

+44
-13
lines changed

components/linkedin/actions/create-image-post-organization/create-image-post-organization.mjs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
import linkedin from "../../linkedin.app.mjs";
22
import { getFileStreamAndMetadata } from "@pipedream/platform";
33
import FormData from "form-data";
4+
import utils from "../../common/utils.mjs";
45

56
export default {
67
key: "linkedin-create-image-post-organization",
78
name: "Create Image Post (Organization)",
8-
description: "Create an image post on LinkedIn. [See the docs here](https://learn.microsoft.com/en-us/linkedin/marketing/integrations/community-management/shares/images-api?view=li-lms-2023-09&tabs=http#uploading-an-image)",
9-
version: "1.0.1",
9+
description: "Create an image post on LinkedIn. [See the documentation](https://learn.microsoft.com/en-us/linkedin/marketing/integrations/community-management/shares/images-api?view=li-lms-2023-09&tabs=http#uploading-an-image)",
10+
version: "1.0.2",
1011
type: "action",
1112
props: {
1213
linkedin,
@@ -87,7 +88,7 @@ export default {
8788
await this.linkedin.createPost({
8889
data: {
8990
author: this.organizationId,
90-
commentary: this.text,
91+
commentary: utils.escapeText(this.text),
9192
visibility: "PUBLIC",
9293
content: {
9394
media: {

components/linkedin/actions/create-image-post-user/create-image-post-user.mjs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
import linkedin from "../../linkedin.app.mjs";
22
import { getFileStreamAndMetadata } from "@pipedream/platform";
33
import FormData from "form-data";
4+
import utils from "../../common/utils.mjs";
45

56
export default {
67
key: "linkedin-create-image-post-user",
78
name: "Create Image Post (User)",
8-
description: "Create an image post on LinkedIn. [See the docs here](https://learn.microsoft.com/en-us/linkedin/marketing/integrations/community-management/shares/images-api?view=li-lms-2023-09&tabs=http#uploading-an-image)",
9-
version: "1.0.1",
9+
description: "Create an image post on LinkedIn. [See the documentation](https://learn.microsoft.com/en-us/linkedin/marketing/integrations/community-management/shares/images-api?view=li-lms-2023-09&tabs=http#uploading-an-image)",
10+
version: "1.0.2",
1011
type: "action",
1112
props: {
1213
linkedin,
@@ -86,7 +87,7 @@ export default {
8687

8788
await this.linkedin.createPost({
8889
data: {
89-
commentary: this.text,
90+
commentary: utils.escapeText(this.text),
9091
visibility: this.visibility,
9192
content: {
9293
media: {

components/linkedin/actions/create-text-post-organization/create-text-post-organization.mjs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import linkedin from "../../linkedin.app.mjs";
2+
import utils from "../../common/utils.mjs";
23

34
export default {
45
key: "linkedin-create-text-post-organization",
56
name: "Create a Simple Post (Organization)",
6-
description: "Create post on LinkedIn using text, URL or article. [See the docs](https://learn.microsoft.com/en-us/linkedin/marketing/integrations/community-management/shares/posts-api?view=li-lms-2022-11&tabs=http#create-organic-posts) for more information",
7-
version: "0.0.6",
7+
description: "Create post on LinkedIn using text, URL or article. [See the documentation](https://learn.microsoft.com/en-us/linkedin/marketing/integrations/community-management/shares/posts-api?view=li-lms-2022-11&tabs=http#create-organic-posts) for more information",
8+
version: "0.0.7",
89
type: "action",
910
props: {
1011
linkedin,
@@ -30,7 +31,7 @@ export default {
3031
async run({ $ }) {
3132
const data = {
3233
author: this.organizationId,
33-
commentary: this.text,
34+
commentary: utils.escapeText(this.text),
3435
visibility: "PUBLIC",
3536
};
3637
if (this.article) {

components/linkedin/actions/create-text-post-user/create-text-post-user.mjs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import linkedin from "../../linkedin.app.mjs";
2+
import utils from "../../common/utils.mjs";
23

34
export default {
45
key: "linkedin-create-text-post-user",
56
name: "Create a Simple Post (User)",
6-
description: "Create post on LinkedIn using text, URL or article. [See the docs](https://learn.microsoft.com/en-us/linkedin/marketing/integrations/community-management/shares/posts-api?view=li-lms-2022-11&tabs=http#create-organic-posts) for more information",
7-
version: "0.0.6",
7+
description: "Create post on LinkedIn using text, URL or article. [See the documentation](https://learn.microsoft.com/en-us/linkedin/marketing/integrations/community-management/shares/posts-api?view=li-lms-2022-11&tabs=http#create-organic-posts) for more information",
8+
version: "0.0.7",
89
type: "action",
910
props: {
1011
linkedin,
@@ -29,7 +30,7 @@ export default {
2930
},
3031
async run({ $ }) {
3132
const data = {
32-
commentary: this.text,
33+
commentary: utils.escapeText(this.text),
3334
visibility: this.visibility,
3435
};
3536
if (this.article) {

components/linkedin/common/utils.mjs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,36 @@ function getParamsSerializer(encodeFn = defaultEncodeFn) {
3030
};
3131
}
3232

33+
function escapeText(text) {
34+
const chars = [
35+
"\\",
36+
"|",
37+
"{",
38+
"}",
39+
"@",
40+
"[",
41+
"]",
42+
"(",
43+
")",
44+
"<",
45+
">",
46+
"#",
47+
"*",
48+
"_",
49+
"~",
50+
];
51+
for (const char of chars) {
52+
const escapedChar = "\\" + char;
53+
const regex = new RegExp(`\\${char}`, "g");
54+
text = text.replace(regex, escapedChar);
55+
}
56+
return text;
57+
}
58+
3359
export default {
3460
iterate,
3561
getNestedProperty,
3662
encodeFn,
3763
getParamsSerializer,
64+
escapeText,
3865
};

components/linkedin/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/linkedin",
3-
"version": "1.1.0",
3+
"version": "1.1.1",
44
"description": "Pipedream Linkedin Components",
55
"main": "linkedin.app.mjs",
66
"keywords": [

0 commit comments

Comments
 (0)