Skip to content

String Escaping/Encoding Bug Fixes#5772

Open
christopherholland-workday wants to merge 1 commit intomainfrom
incomplete-string-escaping
Open

String Escaping/Encoding Bug Fixes#5772
christopherholland-workday wants to merge 1 commit intomainfrom
incomplete-string-escaping

Conversation

@christopherholland-workday
Copy link
Contributor

Related to CodeQL findings

  • 59: packages/components/nodes/sequentialagents/ExecuteFlow/ExecuteFlow.ts:202
  • 61: packages/server/src/utils/buildAgentflow.ts:364
  • 62: packages/server/src/utils/buildAgentflow.ts:392
  • 63: packages/components/nodes/tools/Searxng/Searxng.ts:327

59, 61, 62 are not security issues, more so code smells and potential minor bugs.

For 63 we can remove our own HTML stripping because ReactMarkdown handles all of the stripping/sanitizing already.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request addresses several string escaping and encoding bugs, likely identified by CodeQL. The changes primarily involve replacing single-occurrence string replacements with global regular expression-based replacements to ensure all instances of special characters are correctly handled. This is a good practice for robustness. Additionally, an HTML stripping logic in the Searxng tool has been removed, with the reasoning that ReactMarkdown already handles sanitization. This change also improves safety against potential null or undefined values. The fixes appear correct and well-targeted, though I have a suggestion to make the backslash replacement logic more robust.

const [, nodeIdPart, outputPath] = outputMatch
// Clean nodeId (handle escaped underscores)
const cleanNodeId = nodeIdPart.replace('\\', '')
const cleanNodeId = nodeIdPart.replace(/\\/g, '')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

While using a global replacement is correct, replace(/\\/g, '') is a bit aggressive as it removes all backslashes. This could corrupt strings that are meant to contain literal backslashes (e.g., in paths).

A safer approach is to specifically un-escape only the characters that turndown escapes. According to turndown's implementation, these are: \\, *, _, [, ], (, ), #.

I suggest using a more targeted regex for this.

                const cleanNodeId = nodeIdPart.replace(/\\([\\*_\[\]()#])/g, '$1')

// Find node data in executed data
// sometimes turndown value returns a backslash like `llmAgentflow\_1`, remove the backslash
const cleanNodeId = variableFullPath.replace('\\', '')
const cleanNodeId = variableFullPath.replace(/\\/g, '')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

While using a global replacement is correct, replace(/\\/g, '') is a bit aggressive as it removes all backslashes. This could corrupt strings that are meant to contain literal backslashes (e.g., in paths).

A safer approach is to specifically un-escape only the characters that turndown escapes. According to turndown's implementation, these are: \\, *, _, [, ], (, ), #.

I suggest using a more targeted regex for this.

            const cleanNodeId = variableFullPath.replace(/\\([\\*_\[\]()#])/g, '$1')

@FlowiseAI FlowiseAI deleted a comment from gemini-code-assist bot Feb 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments