import Users from '/imports/api/users'; import Logger from '/imports/startup/server/logger'; import RegexWebUrl from '/imports/utils/regex-weburl'; import { BREAK_LINE } from '/imports/utils/lineEndings'; const MSG_DIRECT_TYPE = 'DIRECT'; const NODE_USER = 'nodeJSapp'; const HTML_SAFE_MAP = { '<': '<', '>': '>', '"': '"', "'": ''', }; export const parseMessage = (message) => { let parsedMessage = message || ''; parsedMessage = parsedMessage.trim(); // Replace
with \n\r parsedMessage = parsedMessage.replace(//gi, '\n\r'); // Sanitize. See: http://shebang.brandonmintern.com/foolproof-html-escaping-in-javascript/ parsedMessage = parsedMessage.replace(/[<>'"]/g, (c) => HTML_SAFE_MAP[c]); // Replace flash links to flash valid ones parsedMessage = parsedMessage.replace(RegexWebUrl, "$&"); // Replace flash links to html valid ones parsedMessage = parsedMessage.split(' { stopped = true; Logger.info(`Publication ${self._name} has stopped in server side`); }); periodicCheck(); };