diff --git a/app/assets/javascripts/components/actions/notifications.jsx b/app/assets/javascripts/components/actions/notifications.jsx index b09ca08545..3707a063b6 100644 --- a/app/assets/javascripts/components/actions/notifications.jsx +++ b/app/assets/javascripts/components/actions/notifications.jsx @@ -25,6 +25,12 @@ const fetchRelatedRelationships = (dispatch, notifications) => { } }; +const unescapeHTML = (html) => { + const wrapper = document.createElement('p'); + wrapper.innerHTML = html; + return wrapper.textContent; +} + export function updateNotifications(notification, intlMessages, intlLocale) { return (dispatch, getState) => { const showAlert = getState().getIn(['settings', 'notifications', 'alerts', notification.type], true); @@ -43,7 +49,7 @@ export function updateNotifications(notification, intlMessages, intlLocale) { // Desktop notifications if (typeof window.Notification !== 'undefined' && showAlert) { const title = new IntlMessageFormat(intlMessages[`notification.${notification.type}`], intlLocale).format({ name: notification.account.display_name.length > 0 ? notification.account.display_name : notification.account.username }); - const body = (notification.status && notification.status.spoiler_text.length > 0) ? notification.status.spoiler_text : $('

').html(notification.status ? notification.status.content : '').text(); + const body = (notification.status && notification.status.spoiler_text.length > 0) ? notification.status.spoiler_text : notification.status ? unescapeHTML(notification.status.content) : ''; new Notification(title, { body, icon: notification.account.avatar, tag: notification.id }); }