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;
|
||||
});
|
||||
}
|
||||
|
|
|
@ -25,6 +25,9 @@ const Names = {
|
|||
8232: "line separator",
|
||||
8237: "left-to-right override",
|
||||
8238: "right-to-left override",
|
||||
8294: "left-to-right isolate",
|
||||
8295: "right-to-left isolate",
|
||||
8297: "pop directional isolate",
|
||||
8233: "paragraph separator",
|
||||
65279: "zero width no-break space",
|
||||
65532: "object replacement"
|
||||
|
@ -32,13 +35,13 @@ const Names = {
|
|||
|
||||
// Regex for Special Characters to be replaced
|
||||
const UnicodeRegexpSupport = /x/.unicode != null ? "gu" : "g";
|
||||
const Specials = new RegExp("[\u0000-\u0008\u000a-\u001f\u007f-\u009f\u00ad\u061c\u200b\u200e\u200f\u2028\u2029\u202d\u202e\ufeff\ufff9-\ufffc\ue000-\uf8ff]", UnicodeRegexpSupport);
|
||||
const Specials = new RegExp("[\u0000-\u0008\u000a-\u001f\u007f-\u009f\u00ad\u061c\u200b\u200e\u200f\u2028\u2029\u202d\u202e\u2066\u2067\u2069\ufeff\ufff9-\ufffc\ue000-\uf8ff]", UnicodeRegexpSupport);
|
||||
|
||||
|
||||
/**
|
||||
* Override for rendering special characters.
|
||||
* Should mirror the toDOM function in
|
||||
* https://github.com/codemirror/view/blob/main/src/special-chars.ts#L150
|
||||
* https://github.com/codemirror/view/blob/main/src/special-chars.ts#L153
|
||||
* But reverts the replacement of line feeds with newline control pictures.
|
||||
*
|
||||
* @param {number} code
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue