diff --git a/package.json b/package.json
index d498e1f..bcc8214 100644
--- a/package.json
+++ b/package.json
@@ -13,6 +13,7 @@
"dependencies": {
"@nitrots/nitro-renderer": "file:submodules/renderer",
"@tanstack/react-virtual": "^3.0.0-beta.60",
+ "dompurify": "^3.0.9",
"emoji-toolkit": "^7.0.1",
"react": "^18.2.0",
"react-bootstrap": "^2.7.2",
@@ -40,4 +41,4 @@
"sass": "1.64.2",
"vite": "^5.0.11"
}
-}
\ No newline at end of file
+}
diff --git a/src/api/utils/RoomChatFormatter.ts b/src/api/utils/RoomChatFormatter.ts
index 17c3c53..a6714cf 100644
--- a/src/api/utils/RoomChatFormatter.ts
+++ b/src/api/utils/RoomChatFormatter.ts
@@ -136,54 +136,46 @@ const encodeHTML = (str: string) =>
});
}
-export const RoomChatFormatter = (content: string) =>
-{
+export const RoomChatFormatter = (content: string) => {
let result = '';
content = encodeHTML(content);
content = content.replace(/\[tag\](.*?)\[\/tag\]/g, '$1');
-
- // Youtube link
- if(!GetConfiguration('youtube.publish.disabled', false)){
- content = content.replace(
- /(?:http:\/\/|https:\/\/)?(?:www\.)?(?:youtube\.com|youtu\.be)\/(?:watch\?.*v=|shorts\/)?([a-zA-Z0-9_-]{11})/g,
- `
-
-
Click on open video to see the YouTube video
-
Open Video
- `
- );
- }
-
-
- if(content.startsWith('@') && content.indexOf('@', 1) > -1)
- {
- let match = null;
-
- while((match = /@[a-zA-Z]+@/g.exec(content)) !== null)
- {
- const colorTag = match[0].toString();
- const colorName = colorTag.substr(1, colorTag.length - 2);
- const text = content.replace(colorTag, '');
-
- if(!allowedColours.has(colorName))
- {
- result = text;
- }
- else
- {
- const color = allowedColours.get(colorName);
- result = '' + text + '';
- }
- break;
- }
+ // Youtube link
+ if (!GetConfiguration('youtube.publish.disabled', false)) {
+ content = content.replace(
+ /(?:http:\/\/|https:\/\/)?(?:www\.)?(?:youtube\.com|youtu\.be)\/(?:watch\?.*v=|shorts\/)?([a-zA-Z0-9_-]{11})/g,
+ `
+
+
Click on open video to see the YouTube video
+
Open Video
+ `
+ );
}
- else
- {
+
+ if (content.includes("giphy.com/media")) {
+ content = `
+
+ `;
+ }
+
+ const match = content.match(/@[a-zA-Z]+@/);
+ if (match) {
+ const colorTag = match[0].toString();
+ const colorName = colorTag.substr(1, colorTag.length - 2);
+ const text = content.replace(colorTag, '');
+
+ if (!allowedColours.has(colorName)) {
+ result = text;
+ } else {
+ const color = allowedColours.get(colorName);
+ result = `${text}`;
+ }
+ } else {
result = content;
}
return result;
-}
\ No newline at end of file
+}