Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.
TypeScript acmeagentsai-agentscertificate-managementdevsecopsenvironment-variableskubernetesopen-sourcepampkipostgresprivate-caprivileged-access-managementsecret-managementsecret-managersecretssecrets-managementsecuritysecurity-toolsvault
feat: fixed tokenization strategy
=34eb9f475a76
diff --git a/backend/src/lib/fn/string.ts b/backend/src/lib/fn/string.tsindex 6e8e5560d1..61e5a7e208 100644--- a/backend/src/lib/fn/string.ts+++ b/backend/src/lib/fn/string.ts@@ -20,10 +20,16 @@ const vowelRegex = new RE2(/^[aeiou]/i);export const startsWithVowel = (str: string) => vowelRegex.test(str);+const pickWordsRegex = new RE2(/(\W+)/);export const sanitizeString = (dto: { unsanitizedString: string; tokens: string[] }) => {- let sanitizedString = dto.unsanitizedString;- dto.tokens.filter(Boolean).forEach((el) => {- sanitizedString = sanitizedString.replaceAll(el, "[REDACTED]");+ const words = dto.unsanitizedString.split(pickWordsRegex);++ const redactionSet = new Set(dto.tokens.filter(Boolean));+ const sanitizedWords = words.map((el) => {+ if (redactionSet.has(el)) {+ return "[REDACTED]";+ }+ return el;});- return sanitizedString;+ return sanitizedWords.join("");};