Skip to content

Potential fix for code scanning alert no. 4: Incomplete string escaping or encoding#214

Merged
projectedanx merged 1 commit into
masterfrom
alert-autofix-4
May 29, 2026
Merged

Potential fix for code scanning alert no. 4: Incomplete string escaping or encoding#214
projectedanx merged 1 commit into
masterfrom
alert-autofix-4

Conversation

@projectedanx
Copy link
Copy Markdown
Owner

Potential fix for https://github.com/projectedanx/YOURLS/security/code-scanning/4

The best fix is to replace the partial/manual escaping with a correct global regex-escaping step before constructing RegExp.

In js/tablesorte.js, inside query_string(key), replace:

  • key = key.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");

with:

  • key = key.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");

This is the standard safe pattern for escaping all regex metacharacters, not just the first [ and ]. It preserves existing functionality (matching the requested query-string key) while removing incomplete escaping risk and handling broader edge cases correctly. No new imports or dependencies are needed.

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: ALifeInArtifyAI <238904666+projectedanx@users.noreply.github.com>
@github-actions
Copy link
Copy Markdown

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

Copy link
Copy Markdown

@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 updates the 'query_string' function in 'js/tablesorte.js' to use a more comprehensive regular expression for escaping special characters in the query string key. The reviewer suggested adding a defensive check to ensure 'key' is a string before calling '.replace()' to prevent potential runtime 'TypeError' crashes.

Comment thread js/tablesorte.js
@projectedanx projectedanx marked this pull request as ready for review May 29, 2026 02:47
@projectedanx projectedanx merged commit acdb2f8 into master May 29, 2026
15 of 17 checks passed
@projectedanx projectedanx deleted the alert-autofix-4 branch May 29, 2026 02:47
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