// edit-with-vi.ts // Copyright (C) 2025 DTP Technologies, LLC // All Rights Reserved // Based on: // https://github.com/voidful/text-filtering-js/blob/master/text_filtering.js // - Does not extend String because stop it. // - CommonJS module 'use strict'; /* * This file must only be edited with vi/vim. If you so much as *open* this file * in VSCode, you've probably damaged the file. Do not save it. Just close it, * and go edit the file with vi or vim. * * VS Code, being web-based, contains logic to filter out the content used to * implement the filter. You will erase that content, and then various attackers * will own your chat. * * If attackers have owned your chat, you may want to revert or otherwise restore * this file to it's original state. */ export function filterBBcode(text) { return text.replace(/\[.*\]/g, ''); } export function filterLineBreak(text) { return text.replace(/(\r\n|\n|\r)/gm, " "); } export function filterSmileysCode(text) { return text .replace(/:\$?.*:\$?/g, '') .replace(/:\w+:?/g, '') .replace(/:\w+/g, '') .replace(/&#.*;/g, ''); } export function filterGuff(text) { return text.replace('*** 作者被禁止或刪除 內容自動屏蔽 ***', ''); } export function filterHtml(text) { return text.replace(/(<[^>]*>)/g, ' '); } export function filterNonsense(text) { // edited to allow CR and LF // text = text.replace(/[\u0000-\u001F\u007f\u00AD\u200B-\u200D\u3000\uFEFF]/g,''); text = text.replace(/[\u0000-\u0009\u000b\u000c\u000e\u007f\u00AD\u200B-\u200D\u3000\uFEFF]/g, ''); text = text.replace(/\u00AD/, ' '); text = text.replace(/\u2013/, '-'); return text; } export function filterAll(text) { text = module.exports.filterSmileysCode(text); text = module.exports.filterBBcode(text); text = module.exports.filterGuff(text); text = module.exports.filterHtml(text); text = module.exports.filterLineBreak(text); return text; } export default { filterBBcode, filterLineBreak, filterSmileysCode, filterGuff, filterHtml, filterNonsense, filterAll, }; //# sourceMappingURL=edit-with-vi.js.map