Skip to content

Potential fix for code scanning alert no. 12: Incomplete string escaping or encoding#55

Closed
NovasPlace wants to merge 1 commit into
masterfrom
alert-autofix-12
Closed

Potential fix for code scanning alert no. 12: Incomplete string escaping or encoding#55
NovasPlace wants to merge 1 commit into
masterfrom
alert-autofix-12

Conversation

@NovasPlace

Copy link
Copy Markdown
Owner

Potential fix for https://github.com/NovasPlace/CSM/security/code-scanning/12

To fix this safely without changing overall behavior, escape backslashes in query before escaping % and _ when building the LIKE pattern.
In src/hybrid-search-sources.ts, line 124 region, replace the current one-step replace with a two-step escape:

  1. \\\\\\ (escape the escape character)
  2. % and _\% and \_

Then wrap with %...% as before.

Best concrete change in the shown code:

  • Replace:
    • const escaped = \%${query.replace(/[%_]/g, '\$&')}%`;`
  • With:
    • const escapedQuery = query.replace(/\\/g, '\\\\').replace(/[%_]/g, '\\$&');
    • const escaped = \%${escapedQuery}%`;`

No new imports or dependencies are required.

Suggested fixes powered by Copilot Autofix. Review carefully before merging.

…ing or encoding

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
@NovasPlace NovasPlace closed this Jul 20, 2026
@NovasPlace
NovasPlace deleted the alert-autofix-12 branch July 20, 2026 07:08
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