mirror of
https://github.com/gchq/CyberChef.git
synced 2025-04-24 00:36:16 -04:00
Added initial input and output UI tests
This commit is contained in:
parent
046a0917e7
commit
05160227a3
4 changed files with 503 additions and 7 deletions
|
@ -835,6 +835,11 @@ class Utils {
|
|||
* Escapes HTML tags in a string to stop them being rendered.
|
||||
* https://www.owasp.org/index.php/XSS_(Cross_Site_Scripting)_Prevention_Cheat_Sheet
|
||||
*
|
||||
* Null bytes are a special case and are converted to a character from the Unicode
|
||||
* Private Use Area, which CyberChef will display as a control character picture.
|
||||
* This is done due to null bytes not being rendered or stored correctly in HTML
|
||||
* DOM building.
|
||||
*
|
||||
* @param {string} str
|
||||
* @returns string
|
||||
*
|
||||
|
@ -849,10 +854,11 @@ class Utils {
|
|||
">": ">",
|
||||
'"': """,
|
||||
"'": "'", // ' not recommended because it's not in the HTML spec
|
||||
"`": "`"
|
||||
"`": "`",
|
||||
"\u0000": "\ue000"
|
||||
};
|
||||
|
||||
return str ? str.replace(/[&<>"'`]/g, function (match) {
|
||||
return str ? str.replace(/[&<>"'`\u0000]/g, function (match) {
|
||||
return HTML_CHARS[match];
|
||||
}) : str;
|
||||
}
|
||||
|
@ -876,10 +882,11 @@ class Utils {
|
|||
""": '"',
|
||||
"'": "'",
|
||||
"/": "/",
|
||||
"`": "`"
|
||||
"`": "`",
|
||||
"\ue000": "\u0000"
|
||||
};
|
||||
|
||||
return str.replace(/&#?x?[a-z0-9]{2,4};/ig, function (match) {
|
||||
return str.replace(/(&#?x?[a-z0-9]{2,4};|\ue000)/ig, function (match) {
|
||||
return HTML_CHARS[match] || match;
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue