From 65bb3b11f3c6fd7fef4fc40cb8fa1b68ebd9b408 Mon Sep 17 00:00:00 2001
From: Hemachandar <132386067+hmacr@users.noreply.github.com>
Date: Fri, 18 Apr 2025 20:15:17 +0530
Subject: [PATCH] fix: Parse emoji and url only as workspace icon (#9009)
* fix: Parse emoji and url only as workspace icon
* scope emoji regex to transform function
---
plugins/notion/server/notion.ts | 13 ++++++++++++-
shared/i18n/locales/en_US/translation.json | 5 -----
2 files changed, 12 insertions(+), 6 deletions(-)
diff --git a/plugins/notion/server/notion.ts b/plugins/notion/server/notion.ts
index f2bf11d170..22a7783517 100644
--- a/plugins/notion/server/notion.ts
+++ b/plugins/notion/server/notion.ts
@@ -13,9 +13,11 @@ import {
RichTextItemResponse,
} from "@notionhq/client/build/src/api-endpoints";
import { RateLimit } from "async-sema";
+import emojiRegex from "emoji-regex";
import compact from "lodash/compact";
import { z } from "zod";
import { Second } from "@shared/utils/time";
+import { isUrl } from "@shared/utils/urls";
import { NotionUtils } from "../shared/NotionUtils";
import { Block, Page, PageType } from "../shared/types";
import env from "./env";
@@ -37,7 +39,16 @@ const AccessTokenResponseSchema = z.object({
bot_id: z.string(),
workspace_id: z.string(),
workspace_name: z.string().nullish(),
- workspace_icon: z.string().url().nullish(),
+ workspace_icon: z
+ .string()
+ .nullish()
+ .transform((val) => {
+ const emojiRegexp = emojiRegex();
+ if (val && (isUrl(val) || emojiRegexp.test(val))) {
+ return val;
+ }
+ return undefined;
+ }),
});
export class NotionClient {
diff --git a/shared/i18n/locales/en_US/translation.json b/shared/i18n/locales/en_US/translation.json
index 8fbf8b128e..69080e8369 100644
--- a/shared/i18n/locales/en_US/translation.json
+++ b/shared/i18n/locales/en_US/translation.json
@@ -520,7 +520,6 @@
"Groups": "Groups",
"Shared Links": "Shared Links",
"Import": "Import",
- "Self Hosted": "Self Hosted",
"Integrations": "Integrations",
"Revoke token": "Revoke token",
"Revoke": "Revoke",
@@ -1045,10 +1044,6 @@
"Allow editors to create new collections within the workspace": "Allow editors to create new collections within the workspace",
"Workspace creation": "Workspace creation",
"Allow editors to create new workspaces": "Allow editors to create new workspaces",
- "Draw.io deployment": "Draw.io deployment",
- "Add your self-hosted draw.io installation url here to enable automatic embedding of diagrams within documents.": "Add your self-hosted draw.io installation url here to enable automatic embedding of diagrams within documents.",
- "Grist deployment": "Grist deployment",
- "Add your self-hosted grist installation URL here.": "Add your self-hosted grist installation URL here.",
"Could not load shares": "Could not load shares",
"Sharing is currently disabled.": "Sharing is currently disabled.",
"You can globally enable and disable public document sharing in the security settings.": "You can globally enable and disable public document sharing in the security settings.",