MCPcopy Index your code
hub / github.com/scriptscat/scriptcat / hasSuspiciousDecodedControlChars

Function hasSuspiciousDecodedControlChars

src/pkg/utils/encoding.ts:163–173  ·  view source on GitHub ↗
(text: string)

Source from the content-addressed store, hash-verified

161};
162
163const hasSuspiciousDecodedControlChars = (text: string): boolean => {
164 let controls = 0;
165 for (let i = 0; i < text.length; i++) {
166 const code = text.charCodeAt(i);
167 if (code === 0xfffd || code === 0) return true;
168 if (code < 0x20 && code !== 0x09 && code !== 0x0a && code !== 0x0d) {
169 controls++;
170 }
171 }
172 return controls > Math.max(4, text.length * 0.02);
173};
174
175/**
176 * Legacy chardet fallback for readBlobContent.

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected