Skip to content

Commit 8aceeb9

Browse files
authored
Merge pull request #399 from jeremykenedy/alert-autofix-3
Fix code scanning alert no. 3: DOM text reinterpreted as HTML
2 parents e03c64a + 50fb0c7 commit 8aceeb9

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

resources/js/services/excanvas.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -846,6 +846,15 @@ if (!document.createElement('canvas').getContext) {
846846
const w2 = sw / 2;
847847
const h2 = sh / 2;
848848

849+
function escapeHtml(unsafe) {
850+
return unsafe
851+
.replace(/&/g, "&")
852+
.replace(/</g, "&lt;")
853+
.replace(/>/g, "&gt;")
854+
.replace(/"/g, "&quot;")
855+
.replace(/'/g, "&#039;");
856+
}
857+
849858
const vmlStr = [];
850859

851860
const W = 10;
@@ -928,7 +937,7 @@ if (!document.createElement('canvas').getContext) {
928937
vmlStr.push(
929938
' ">',
930939
'<g_vml_:image src="',
931-
image.src,
940+
escapeHtml(image.src),
932941
'"',
933942
' style="width:',
934943
Z * dw,

0 commit comments

Comments
 (0)