diff --git a/cypress/platform/xss15.html b/cypress/platform/xss15.html index a2d882dff..94506def5 100644 --- a/cypress/platform/xss15.html +++ b/cypress/platform/xss15.html @@ -70,7 +70,7 @@ // fontFamily: 'courier', fontSize: 18, curve: 'basis', - securityLevel: 'strict ', + securityLevel: 'strict', startOnLoad: false, secure: ['secure', 'securityLevel', 'startOnLoad', 'maxTextSize'], // themeVariables: {relationLabelColor: 'red'} @@ -90,7 +90,7 @@ var diagram = `sequenceDiagram participant John links John: {"XSS": "javas`; -diagram += 'cript:alert(window.opener.document.domain)"}'; +diagram += `cript:alert('AudioParam')"}`; // var diagram = "stateDiagram-v2\n"; // diagram += " { return str.split('#br#'); }; +export const removeEscapes = (text) => { + let newStr = text.replace(/\\u[\dA-F]{4}/gi, function (match) { + return String.fromCharCode(parseInt(match.replace(/\\u/g, ''), 16)); + }); + + console.log(newStr); + + newStr = newStr.replace(/\\x([0-9a-f]{2})/gi, (_, c) => String.fromCharCode(parseInt(c, 16))); + newStr = newStr.replace(/\\[\d\d\d]{3}/gi, function (match) { + return String.fromCharCode(parseInt(match.replace(/\\/g, ''), 8)); + }); + newStr = newStr.replace(/\\[\d\d\d]{2}/gi, function (match) { + return String.fromCharCode(parseInt(match.replace(/\\/g, ''), 8)); + }); + + return newStr; +}; + /** * Removes script tags from a text * @@ -40,13 +58,12 @@ export const removeScript = (txt) => { break; } } - - rs = rs.replace(/script>/gi, '#'); - rs = rs.replace(/script>/gi, '#'); - rs = rs.replace(/javascript:/gi, '#'); - rs = rs.replace(/onerror=/gi, 'onerror:'); - rs = rs.replace(/