diff --git a/src/SlashCommands.js b/src/SlashCommands.js index f31bf32eac..be1f4ebda8 100644 --- a/src/SlashCommands.js +++ b/src/SlashCommands.js @@ -27,12 +27,7 @@ import SettingsStore, {SettingLevel} from './settings/SettingsStore'; import {MATRIXTO_URL_PATTERN} from "./linkify-matrix"; import * as querystring from "querystring"; import MultiInviter from './utils/MultiInviter'; -import * as linkify from 'linkifyjs'; -import linkifyString from 'linkifyjs/string'; -import linkifyMatrix from './linkify-matrix'; -import sanitizeHtml from 'sanitize-html'; - -linkifyMatrix(linkify); +import { linkifyAndSanitizeHtml } from './HtmlUtils'; class Command { constructor({name, args='', description, runFn, hideCompletionAfterSpace=false}) { @@ -154,7 +149,7 @@ export const CommandMap = { const topicEvents = room.currentState.getStateEvents('m.room.topic', ''); const topic = topicEvents.getContent().topic; - const topicHtml = topic ? linkifyString(sanitizeHtml(topic)) : _t('This room has no topic.'); + const topicHtml = topic ? linkifyAndSanitizeHtml(topic) : _t('This room has no topic.'); const InfoDialog = sdk.getComponent('dialogs.InfoDialog'); Modal.createTrackedDialog('Slash Commands', 'Topic', InfoDialog, { diff --git a/src/components/structures/RoomDirectory.js b/src/components/structures/RoomDirectory.js index c18dd4d48a..08d3403bc3 100644 --- a/src/components/structures/RoomDirectory.js +++ b/src/components/structures/RoomDirectory.js @@ -24,10 +24,7 @@ const Modal = require('../../Modal'); const sdk = require('../../index'); const dis = require('../../dispatcher'); -const linkify = require('linkifyjs'); -const linkifyString = require('linkifyjs/string'); -const linkifyMatrix = require('../../linkify-matrix'); -const sanitizeHtml = require('sanitize-html'); +import { linkifyAndSanitizeHtml } from '../../HtmlUtils'; import Promise from 'bluebird'; import { _t } from '../../languageHandler'; @@ -37,8 +34,6 @@ import {instanceForInstanceId, protocolNameForInstanceId} from '../../utils/Dire const MAX_NAME_LENGTH = 80; const MAX_TOPIC_LENGTH = 160; -linkifyMatrix(linkify); - module.exports = React.createClass({ displayName: 'RoomDirectory', @@ -438,7 +433,7 @@ module.exports = React.createClass({ if (topic.length > MAX_TOPIC_LENGTH) { topic = `${topic.substring(0, MAX_TOPIC_LENGTH)}...`; } - topic = linkifyString(sanitizeHtml(topic)); + topic = linkifyAndSanitizeHtml(topic); rows.push(