mirror of
https://github.com/gchq/CyberChef
synced 2026-01-04 09:33:21 +00:00
BUGFIX: HTML output which is then converted to a regular string (for a standard operation) still contained escaped HTML chars.
This commit is contained in:
@@ -139,7 +139,7 @@ Dish.prototype.translate = function(toType) {
|
||||
this.type = Dish.BYTE_ARRAY;
|
||||
break;
|
||||
case Dish.HTML:
|
||||
this.value = this.value ? Utils.strToByteArray(Utils.stripHtmlTags(this.value, true)) : [];
|
||||
this.value = this.value ? Utils.strToByteArray(Utils.unescapeHtml(Utils.stripHtmlTags(this.value, true))) : [];
|
||||
this.type = Dish.BYTE_ARRAY;
|
||||
break;
|
||||
default:
|
||||
|
||||
@@ -928,6 +928,33 @@ var Utils = {
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* Unescapes HTML tags in a string to make them render again.
|
||||
*
|
||||
* @param {string} str
|
||||
* @returns string
|
||||
*
|
||||
* @example
|
||||
* // return "A <script> tag"
|
||||
* Utils.unescapeHtml("A <script> tag");
|
||||
*/
|
||||
unescapeHtml: function(str) {
|
||||
var HTML_CHARS = {
|
||||
"&": "&",
|
||||
"<": "<",
|
||||
">": ">",
|
||||
""": '"',
|
||||
"'": "'",
|
||||
"/": "/",
|
||||
"`": "`"
|
||||
};
|
||||
|
||||
return str.replace(/&#?x?[a-z0-9]{2,4};/ig, function (match) {
|
||||
return HTML_CHARS[match] || match;
|
||||
});
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* Expresses a number of milliseconds in a human readable format.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user