Merge branch 'release/4.5.2'

This commit is contained in:
Sojan Jose
2025-08-20 21:45:34 +02:00
6 changed files with 7 additions and 35 deletions

View File

@@ -50,35 +50,11 @@ const updateCampaignReadStatus = baseDomain => {
}); });
}; };
const sanitizeURL = url => {
if (url === '') return '';
try {
// any invalid url will not be accepted
// example - JaVaScRiP%0at:alert(document.domain)"
// this has an obfuscated javascript protocol
const parsedURL = new URL(url);
// filter out dangerous protocols like `javascript`, `data`, `vbscript`
if (!['https', 'http'].includes(parsedURL.protocol)) {
throw new Error('Invalid Protocol');
}
} catch (e) {
// eslint-disable-next-line no-console
console.error('Invalid URL', e);
}
return 'about:blank'; // blank page URL
};
export const IFrameHelper = { export const IFrameHelper = {
getUrl({ baseUrl, websiteToken }) { getUrl({ baseUrl, websiteToken }) {
baseUrl = sanitizeURL(baseUrl);
return `${baseUrl}/widget?website_token=${websiteToken}`; return `${baseUrl}/widget?website_token=${websiteToken}`;
}, },
createFrame: ({ baseUrl, websiteToken }) => { createFrame: ({ baseUrl, websiteToken }) => {
baseUrl = sanitizeURL(baseUrl);
if (IFrameHelper.getAppFrame()) { if (IFrameHelper.getAppFrame()) {
return; return;
} }
@@ -126,12 +102,10 @@ export const IFrameHelper = {
window.onmessage = e => { window.onmessage = e => {
if ( if (
typeof e.data !== 'string' || typeof e.data !== 'string' ||
e.data.indexOf('chatwoot-widget:') !== 0 || e.data.indexOf('chatwoot-widget:') !== 0
e.origin !== window.location.origin
) { ) {
return; return;
} }
const message = JSON.parse(e.data.replace('chatwoot-widget:', '')); const message = JSON.parse(e.data.replace('chatwoot-widget:', ''));
if (typeof IFrameHelper.events[message.event] === 'function') { if (typeof IFrameHelper.events[message.event] === 'function') {
IFrameHelper.events[message.event](message); IFrameHelper.events[message.event](message);
@@ -166,9 +140,7 @@ export const IFrameHelper = {
}, },
setupAudioListeners: () => { setupAudioListeners: () => {
let { baseUrl = '' } = window.$chatwoot; const { baseUrl = '' } = window.$chatwoot;
baseUrl = sanitizeURL(baseUrl);
getAlertAudio(baseUrl, { type: 'widget', alertTone: 'ding' }).then(() => getAlertAudio(baseUrl, { type: 'widget', alertTone: 'ding' }).then(() =>
initOnEvents.forEach(event => { initOnEvents.forEach(event => {
document.removeEventListener( document.removeEventListener(
@@ -262,7 +234,6 @@ export const IFrameHelper = {
}, },
popoutChatWindow: ({ baseUrl, websiteToken, locale }) => { popoutChatWindow: ({ baseUrl, websiteToken, locale }) => {
baseUrl = sanitizeURL(baseUrl);
const cwCookie = Cookies.get('cw_conversation'); const cwCookie = Cookies.get('cw_conversation');
window.$chatwoot.toggle('close'); window.$chatwoot.toggle('close');
popoutChatWindow(baseUrl, websiteToken, locale, cwCookie); popoutChatWindow(baseUrl, websiteToken, locale, cwCookie);

View File

@@ -3,7 +3,7 @@
# Table name: assignment_policies # Table name: assignment_policies
# #
# id :bigint not null, primary key # id :bigint not null, primary key
# assignment_order :integer default(0), not null # assignment_order :integer default("round_robin"), not null
# conversation_priority :integer default("earliest_created"), not null # conversation_priority :integer default("earliest_created"), not null
# description :text # description :text
# enabled :boolean default(TRUE), not null # enabled :boolean default(TRUE), not null

View File

@@ -19,6 +19,7 @@
# #
# Indexes # Indexes
# #
# idx_notifications_performance (user_id,account_id,snoozed_until,read_at)
# index_notifications_on_account_id (account_id) # index_notifications_on_account_id (account_id)
# index_notifications_on_last_activity_at (last_activity_at) # index_notifications_on_last_activity_at (last_activity_at)
# index_notifications_on_user_id (user_id) # index_notifications_on_user_id (user_id)

View File

@@ -1,5 +1,5 @@
shared: &shared shared: &shared
version: '4.5.1' version: '4.5.2'
development: development:
<<: *shared <<: *shared

View File

@@ -1,5 +1,5 @@
class AddTemplateParamsToCampaigns < ActiveRecord::Migration[7.1] class AddTemplateParamsToCampaigns < ActiveRecord::Migration[7.1]
def change def change
add_column :campaigns, :template_params, :jsonb, default: {}, null: false add_column :campaigns, :template_params, :jsonb
end end
end end

View File

@@ -1,6 +1,6 @@
{ {
"name": "@chatwoot/chatwoot", "name": "@chatwoot/chatwoot",
"version": "4.5.1", "version": "4.5.2",
"license": "MIT", "license": "MIT",
"scripts": { "scripts": {
"eslint": "eslint app/**/*.{js,vue}", "eslint": "eslint app/**/*.{js,vue}",