(
text,
rulesText = datasec_blocklist_default,
)
| 2805 | }; |
| 2806 | |
| 2807 | const sanitizeDataSecText = function ( |
| 2808 | text, |
| 2809 | rulesText = datasec_blocklist_default, |
| 2810 | ) { |
| 2811 | let result = `${text || ""}`; |
| 2812 | const matches = []; |
| 2813 | `${rulesText || ""}`.split(`\n`).forEach((ruleText) => { |
| 2814 | if (!ruleText) return; |
| 2815 | try { |
| 2816 | const rule = new RegExp(ruleText, "g"); |
| 2817 | const found = result.match(rule) || []; |
| 2818 | found.forEach((item) => { |
| 2819 | if (!matches.includes(item)) matches.push(item); |
| 2820 | }); |
| 2821 | result = result.replace(rule, ``); |
| 2822 | } catch (e) { |
| 2823 | if (gv("k_showDebug", false) === true) { |
| 2824 | console.log(`KeepChatGPT: DATASEC: ERROR: ${e}`); |
| 2825 | } |
| 2826 | } |
| 2827 | }); |
| 2828 | return { text: result, matches: matches }; |
| 2829 | }; |
| 2830 | |
| 2831 | const setPromptPlainText = function (promptTextarea, text) { |
| 2832 | promptTextarea.focus(); |
no test coverage detected