MCPcopy Create free account
hub / github.com/garrytan/gstack / datamarkContent

Function datamarkContent

browse/src/content-security.ts:44–59  ·  view source on GitHub ↗
(content: string)

Source from the content-addressed store, hash-verified

42 * Only applied to `text` command output (not html, forms, or structured data).
43 */
44export function datamarkContent(content: string): string {
45 const marker = ensureMarker();
46 // Insert marker as a Unicode tag sequence between sentences (after periods followed by space)
47 // This is subtle enough to not corrupt output but detectable if exfiltrated
48 const zwsp = '\u200B'; // zero-width space
49 const taggedMarker = marker.split('').map(c => zwsp + c).join('');
50 // Insert after every 3rd sentence-ending period
51 let count = 0;
52 return content.replace(/(\. )/g, (match) => {
53 count++;
54 if (count % 3 === 0) {
55 return match + taggedMarker;
56 }
57 return match;
58 });
59}
60
61// ─── Hidden Element Stripping (Layer 2) ─────────────────────────
62

Calls 1

ensureMarkerFunction · 0.85

Tested by

no test coverage detected