Skip to content

Potential fix for code scanning alert no. 4: Double escaping or unescaping#10

Merged
aunghtetnay merged 1 commit intomainfrom
fixed-escaping
Oct 8, 2025
Merged

Potential fix for code scanning alert no. 4: Double escaping or unescaping#10
aunghtetnay merged 1 commit intomainfrom
fixed-escaping

Conversation

@aunghtetnay
Copy link
Contributor

Potential fix for https://github.com/patchwork-hub/patchwork-web-app/security/code-scanning/4

To fix the problem, we need to ensure that the unescaping (decoding) of the HTML entities in cleanText is performed in the correct order: do not decode the escape character (&) before decoding the other entities. Instead, decode all other entities first, and only decode & last.

Specifically, in the cleanText function, move the .replace(/&amp;/gi, "&") line so it comes after all other .replace() calls that decode entity references for <, >, ", ', and nbsp. This ensures that character references like &amp;lt; are not mistakenly decoded as <.

All the changes are within the code shown, specifically in the cleanText method in src/utils/helper/socialLink.ts (lines 50–61). No new methods, imports, or external libraries are required; only the order of replacement operations inside cleanText needs to be changed.

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

…aping

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
@aunghtetnay aunghtetnay marked this pull request as ready for review October 8, 2025 07:26
@aunghtetnay aunghtetnay merged commit 8a5394c into main Oct 8, 2025
5 checks passed
@aunghtetnay aunghtetnay deleted the fixed-escaping branch October 8, 2025 11: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