Move decodeHTMLEntities util into headless

This commit is contained in:
ubermanu 2021-05-21 17:37:21 +02:00 committed by JC Brand
parent 8701708b53
commit 2f7dcb6bbc
3 changed files with 13 additions and 13 deletions

View File

@ -2,7 +2,7 @@ import dayjs from 'dayjs';
import sizzle from 'sizzle';
import { Strophe } from 'strophe.js/src/strophe';
import { _converse, api } from '@converse/headless/core';
import { decodeHTMLEntities } from 'shared/utils';
import { decodeHTMLEntities } from '@converse/headless/shared/utils';
import { rejectMessage } from '@converse/headless/shared/actions';
const { NS } = Strophe;

View File

@ -2,6 +2,7 @@ import Storage from '@converse/skeletor/src/storage.js';
import log from '@converse/headless/log';
import { _converse, api } from '@converse/headless/core';
import { getOpenPromise } from '@converse/openpromise';
import xss from 'xss/dist/xss';
export function getDefaultStore () {
if (_converse.config.get('trusted')) {
@ -45,3 +46,14 @@ export function replacePromise (name) {
log.debug(`Not replacing promise "${name}"`);
}
}
const element = document.createElement('div');
export function decodeHTMLEntities (str) {
if (str && typeof str === 'string') {
element.innerHTML = xss.filterXSS(str);
str = element.textContent;
element.textContent = '';
}
return str;
}

View File

@ -1,12 +0,0 @@
import xss from 'xss/dist/xss';
const element = document.createElement('div');
export function decodeHTMLEntities (str) {
if (str && typeof str === 'string') {
element.innerHTML = xss.filterXSS(str);
str = element.textContent;
element.textContent = '';
}
return str;
}