Skip to content

Commit b751e2b

Browse files
authored
Merge pull request #61 from EngineScript/alert-autofix-14
Potential fix for code scanning alert no. 14: Incomplete multi-character sanitization
2 parents ab700c8 + a7607ea commit b751e2b

1 file changed

Lines changed: 13 additions & 9 deletions

File tree

config/var/www/admin/control-panel/dashboard.js

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -893,15 +893,19 @@ class EngineScriptDashboard {
893893

894894
// For logs, we allow more characters but still remove dangerous patterns
895895
// Keep line breaks and basic formatting for readability but remove XSS vectors
896-
return input
897-
.replace(/\0/g, '') // Remove null bytes first
898-
.replace(/[<>&"'`]/g, '') // Remove HTML/XML special characters that could break out of attributes
899-
.replace(/javascript:/gi, '') // Remove javascript: protocol
900-
.replace(/data:/gi, '') // Remove data: protocol
901-
.replace(/vbscript:/gi, '') // Remove vbscript: protocol
902-
.replace(/on\w+=/gi, '') // Remove event handlers
903-
.replace(/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F]/g, '') // Remove control chars but keep \t, \n, \r
904-
.substring(0, 50000); // Reasonable log size limit
896+
let previous;
897+
do {
898+
previous = input;
899+
input = input
900+
.replace(/\0/g, '') // Remove null bytes first
901+
.replace(/[<>&"'`]/g, '') // Remove HTML/XML special characters that could break out of attributes
902+
.replace(/javascript:/gi, '') // Remove javascript: protocol
903+
.replace(/data:/gi, '') // Remove data: protocol
904+
.replace(/vbscript:/gi, '') // Remove vbscript: protocol
905+
.replace(/on\w+=/gi, '') // Remove event handlers
906+
.replace(/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F]/g, ''); // Remove control chars but keep \t, \n, \r
907+
} while (input !== previous);
908+
return input.substring(0, 50000); // Reasonable log size limit
905909
}
906910

907911
setTextContent(elementId, content) {

0 commit comments

Comments
 (0)