Skip to content

Conversation

turtledreams
Copy link

@turtledreams turtledreams commented Oct 2, 2025

image

Comment on lines +16 to +17
return str.replace(/"/g, '"')
.replace(/&/g, '&')

Check failure

Code scanning / CodeQL

Double escaping or unescaping High test

This replacement may produce '&' characters that are double-unescaped
here
.

Copilot Autofix

AI about 15 hours ago

To fix the double unescaping problem, we need to reorder the replacements in the unescapeHtml function. Specifically, all replacements that introduce ampersands (&) should be performed after other entity replacements. This means the unescaping for & must occur after unescaping ", <, >, and '. Therefore, modify the function in plugins/sdk/tests/validation_tests.js at line 16-20 so that .replace(/&/g, '&') is done last. No extra imports or definitions are needed for native JS replace.


Suggested changeset 1
plugins/sdk/tests/validation_tests.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/plugins/sdk/tests/validation_tests.js b/plugins/sdk/tests/validation_tests.js
--- a/plugins/sdk/tests/validation_tests.js
+++ b/plugins/sdk/tests/validation_tests.js
@@ -14,10 +14,10 @@
             return str;
         }
         return str.replace(/&quot;/g, '"')
-            .replace(/&amp;/g, '&')
             .replace(/&lt;/g, '<')
             .replace(/&gt;/g, '>')
-            .replace(/&#39;/g, "'");
+            .replace(/&#39;/g, "'")
+            .replace(/&amp;/g, '&');
     }
     before(function(done) {
         const enforcement = {
EOF
@@ -14,10 +14,10 @@
return str;
}
return str.replace(/&quot;/g, '"')
.replace(/&amp;/g, '&')
.replace(/&lt;/g, '<')
.replace(/&gt;/g, '>')
.replace(/&#39;/g, "'");
.replace(/&#39;/g, "'")
.replace(/&amp;/g, '&');
}
before(function(done) {
const enforcement = {
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