Skip to content

Potential fix for code scanning alert no. 2: Incomplete string escaping or encoding - #39

Open
amineelm0 wants to merge 2 commits into
mainfrom
alert-autofix-2
Open

amineelm0 wants to merge 2 commits into
mainfrom
alert-autofix-2

Conversation

@amineelm0

Copy link
Copy Markdown
Contributor

Potential fix for https://github.com/docusign/pangaea/security/code-scanning/2

To fix this safely without changing behavior, avoid ad-hoc quote escaping and instead serialize the selector as a proper JavaScript string literal using JSON.stringify. This automatically escapes backslashes, quotes, control characters, and other edge cases correctly.

Best change in packages/devtools-extension/src/services/highlight/highlightScriptGenerator.ts:

  • Replace the current escapedSelector computation (replace(/'/g, "\\'")) with JSON.stringify(elementSelector).
  • Update the template usage at document.querySelector(...) to inject the already-quoted serialized literal directly (remove the surrounding manual single quotes).

This preserves functionality (same selector value passed to querySelector) while eliminating incomplete escaping risk.

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

…ng or encoding

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Signed-off-by: amineelm0 <amine.elmouradi@docusign.com>
@amineelm0
amineelm0 marked this pull request as ready for review October 9, 2026 10:52
@amineelm0
amineelm0 requested a review from a team October 9, 2026 10:52
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