Skip to content

Conversation

evalstate
Copy link
Owner

No description provided.

@evalstate evalstate merged commit 9900719 into main Apr 16, 2025
1 check passed

// Helper function to escape markdown special characters in table cells
function escapeMarkdown(text: string): string {
return text.replace(/\|/g, "\\|").replace(/\n/g, " ");

Check failure

Code scanning / CodeQL

Incomplete string escaping or encoding High

This does not escape backslash characters in the input.

Copilot Autofix

AI 5 months ago

To fix the problem, we need to ensure that backslashes are also escaped in the escapeMarkdown function. This can be done by adding an additional replace call to handle backslashes. The best way to fix this without changing existing functionality is to modify the escapeMarkdown function to include a regular expression that escapes backslashes before escaping other characters.

Suggested changeset 1
src/semantic_search.ts

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/src/semantic_search.ts b/src/semantic_search.ts
--- a/src/semantic_search.ts
+++ b/src/semantic_search.ts
@@ -97,3 +97,3 @@
 function escapeMarkdown(text: string): string {
-  return text.replace(/\|/g, "\\|").replace(/\n/g, " ");
+  return text.replace(/\\/g, "\\\\").replace(/\|/g, "\\|").replace(/\n/g, " ");
 }
EOF
@@ -97,3 +97,3 @@
function escapeMarkdown(text: string): string {
return text.replace(/\|/g, "\\|").replace(/\n/g, " ");
return text.replace(/\\/g, "\\\\").replace(/\|/g, "\\|").replace(/\n/g, " ");
}
Copilot is powered by AI and may make mistakes. Always verify output.
Unable to commit as this autofix suggestion is now outdated
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.

1 participant