From 5560abf459b0350ff30b5e71d4208418fc8f3b3e Mon Sep 17 00:00:00 2001 From: TheCatLady <52870424+TheCatLady@users.noreply.github.com> Date: Wed, 24 Feb 2021 23:14:32 -0500 Subject: [PATCH] fix(notif): escape application title in Telegram notifications (#1012) --- server/lib/notifications/agents/telegram.ts | 3 ++- .../Settings/Notifications/NotificationsTelegram.tsx | 8 ++++---- src/i18n/locale/en.json | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/server/lib/notifications/agents/telegram.ts b/server/lib/notifications/agents/telegram.ts index 9913d35e6..fd3b4dd9f 100644 --- a/server/lib/notifications/agents/telegram.ts +++ b/server/lib/notifications/agents/telegram.ts @@ -53,6 +53,7 @@ class TelegramAgent const title = this.escapeText(payload.subject); const plot = this.escapeText(payload.message); const user = this.escapeText(payload.notifyUser.displayName); + const applicationTitle = this.escapeText(settings.main.applicationTitle); /* eslint-disable no-useless-escape */ switch (type) { @@ -109,7 +110,7 @@ class TelegramAgent if (settings.main.applicationUrl && payload.media) { const actionUrl = `${settings.main.applicationUrl}/${payload.media.mediaType}/${payload.media.tmdbId}`; - message += `\n\n\[Open in ${settings.main.applicationTitle}\]\(${actionUrl}\)`; + message += `\n\n\[Open in ${applicationTitle}\]\(${actionUrl}\)`; } /* eslint-enable */ diff --git a/src/components/Settings/Notifications/NotificationsTelegram.tsx b/src/components/Settings/Notifications/NotificationsTelegram.tsx index bc626fd55..abfd8b0af 100644 --- a/src/components/Settings/Notifications/NotificationsTelegram.tsx +++ b/src/components/Settings/Notifications/NotificationsTelegram.tsx @@ -17,7 +17,7 @@ const messages = defineMessages({ botAPI: 'Bot Authentication Token', chatId: 'Chat ID', validationBotAPIRequired: 'You must provide a bot authentication token', - validationChatIdRequired: 'You must provide a valid chat ID', + validationChatIdRequired: 'You must provide a chat ID', telegramsettingssaved: 'Telegram notification settings saved successfully!', telegramsettingsfailed: 'Telegram notification settings failed to save.', testsent: 'Test notification sent!', @@ -43,9 +43,9 @@ const NotificationsTelegram: React.FC = () => { botAPI: Yup.string().required( intl.formatMessage(messages.validationBotAPIRequired) ), - chatId: Yup.string() - .required(intl.formatMessage(messages.validationChatIdRequired)) - .matches(/^\d+$/, intl.formatMessage(messages.validationChatIdRequired)), + chatId: Yup.string().required( + intl.formatMessage(messages.validationChatIdRequired) + ), }); if (!data && !error) { diff --git a/src/i18n/locale/en.json b/src/i18n/locale/en.json index 082836caa..2c4e6b5bb 100644 --- a/src/i18n/locale/en.json +++ b/src/i18n/locale/en.json @@ -326,7 +326,7 @@ "components.Settings.Notifications.test": "Test", "components.Settings.Notifications.testsent": "Test notification sent!", "components.Settings.Notifications.validationBotAPIRequired": "You must provide a bot authentication token", - "components.Settings.Notifications.validationChatIdRequired": "You must provide a valid chat ID", + "components.Settings.Notifications.validationChatIdRequired": "You must provide a chat ID", "components.Settings.Notifications.validationEmail": "You must provide a valid email address", "components.Settings.Notifications.validationSmtpHostRequired": "You must provide an SMTP host", "components.Settings.Notifications.validationSmtpPortRequired": "You must provide an SMTP port",