MCPcopy Index your code
hub / github.com/FlowiseAI/Flowise / sanitizeNullBytes

Function sanitizeNullBytes

packages/server/src/utils/sanitize.util.ts:4–35  ·  view source on GitHub ↗
(obj: any)

Source from the content-addressed store, hash-verified

2import { isIPv4, isIPv6, isValidIPAddress } from './ipValidation'
3
4export function sanitizeNullBytes(obj: any): any {
5 const stack = [obj]
6
7 while (stack.length) {
8 const current = stack.pop()
9
10 if (Array.isArray(current)) {
11 for (let i = 0; i < current.length; i++) {
12 const val = current[i]
13 if (typeof val === 'string') {
14 // eslint-disable-next-line no-control-regex
15 current[i] = val.replace(/\u0000/g, '')
16 } else if (val && typeof val === 'object') {
17 stack.push(val)
18 }
19 }
20 } else if (current && typeof current === 'object') {
21 for (const key in current) {
22 if (!Object.hasOwnProperty.call(current, key)) continue
23 const val = current[key]
24 if (typeof val === 'string') {
25 // eslint-disable-next-line no-control-regex
26 current[key] = val.replace(/\u0000/g, '')
27 } else if (val && typeof val === 'object') {
28 stack.push(val)
29 }
30 }
31 }
32 }
33
34 return obj
35}
36
37export function sanitizeUser(user: Partial<User>) {
38 delete user.credential

Callers 3

importDataFunction · 0.90
sanitizeAuditMetadataFunction · 0.85

Calls 1

callMethod · 0.45

Tested by

no test coverage detected