Skip to content

Added better search haha #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Added better search haha #4

wants to merge 1 commit into from

Conversation

Alimadcorp
Copy link
Collaborator

No description provided.

Copy link

vercel bot commented Jan 25, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
note-plus ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 25, 2025 7:16pm


const wordBoundary = wholeWordCheckbox.checked ? "\\b" : "";
const regex = new RegExp(
`${wordBoundary}${oldWord.replace(/\//g, "\\/")}${wordBoundary}`,

Check failure

Code scanning / CodeQL

Incomplete string escaping or encoding High

This does not escape backslash characters in the input.

Copilot Autofix

AI 4 months ago

To fix the problem, we need to ensure that backslashes in oldWord are properly escaped before using it in a regular expression. This can be done by adding a replace call to escape backslashes before escaping forward slashes. This ensures that all occurrences of backslashes are correctly handled.

We will modify the line where oldWord is processed to escape backslashes first, followed by forward slashes. This change will be made in the replaceWord function.

Suggested changeset 1
public/js/search.js

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/public/js/search.js b/public/js/search.js
--- a/public/js/search.js
+++ b/public/js/search.js
@@ -105,3 +105,3 @@
   const regex = new RegExp(
-    `${wordBoundary}${oldWord.replace(/\//g, "\\/")}${wordBoundary}`,
+    `${wordBoundary}${oldWord.replace(/\\/g, "\\\\").replace(/\//g, "\\/")}${wordBoundary}`,
     flags
EOF
@@ -105,3 +105,3 @@
const regex = new RegExp(
`${wordBoundary}${oldWord.replace(/\//g, "\\/")}${wordBoundary}`,
`${wordBoundary}${oldWord.replace(/\\/g, "\\\\").replace(/\//g, "\\/")}${wordBoundary}`,
flags
Copilot is powered by AI and may make mistakes. Always verify output.
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