Merge remote-tracking branch 'upstream/master' into feature_xpath

This commit is contained in:
Mike Schwörer 2016-12-05 20:16:39 +01:00
commit 5c92e49d5d
No known key found for this signature in database
GPG key ID: D3C7172E0A70F8CF
12 changed files with 116 additions and 57 deletions

View file

@ -209,7 +209,7 @@ var OperationConfig = {
]
},
"XOR": {
description: "XOR the input with the given key.<br>e.g. <code>fe023da5</code><br><br><strong>Options</strong><br><u>Null preserving:</u> If the current byte is 0x00 or the same as the key, skip it.<br><br><u>Differential:</u> Set the key to the value of the previously decoded byte.",
description: "XOR the input with the given key.<br>e.g. <code>fe023da5</code><br><br><strong>Options</strong><br><u>Null preserving:</u> If the current byte is 0x00 or the same as the key, skip it.<br><br><u>Scheme:</u><ul><li>Standard - key is unchanged after each round</li><li>Input differential - key is set to the value of the previous unprocessed byte</li><li>Output differential - key is set to the value of the previous processed byte</li></ul>",
run: BitwiseOp.run_xor,
highlight: true,
highlight_reverse: true,
@ -222,15 +222,15 @@ var OperationConfig = {
value: "",
toggle_values: BitwiseOp.KEY_FORMAT
},
{
name: "Scheme",
type: "option",
value: BitwiseOp.XOR_SCHEME
},
{
name: "Null preserving",
type: "boolean",
value: BitwiseOp.XOR_PRESERVE_NULLS
},
{
name: "Differential",
type: "boolean",
value: BitwiseOp.XOR_DIFFERENTIAL
}
]
},

View file

@ -875,7 +875,10 @@ var Utils = {
* Utils.escape_html("A <script> tag");
*/
escape_html: function(str) {
return str.replace(/</g, "&lt;");
return str.replace(/</g, "&lt;")
.replace(/'/g, "&apos;")
.replace(/"/g, '&quot;')
.replace(/&/g, "&amp;");
},

View file

@ -215,21 +215,21 @@ var Base64 = {
if (len0 % 4 == 2) {
static_section = offset0.slice(0, -3);
offset0 = "<span data-toggle='tooltip' data-placement='top' title='" +
Utils.from_base64(static_section, alphabet).slice(0, -2) + "'>" +
Utils.escape_html(Utils.from_base64(static_section, alphabet).slice(0, -2)) + "'>" +
static_section + "</span>" +
"<span class='hlgreen'>" + offset0.substr(offset0.length - 3, 1) + "</span>" +
"<span class='hlred'>" + offset0.substr(offset0.length - 2) + "</span>";
} else if (len0 % 4 == 3) {
static_section = offset0.slice(0, -2);
offset0 = "<span data-toggle='tooltip' data-placement='top' title='" +
Utils.from_base64(static_section, alphabet).slice(0, -1) + "'>" +
Utils.escape_html(Utils.from_base64(static_section, alphabet).slice(0, -1)) + "'>" +
static_section + "</span>" +
"<span class='hlgreen'>" + offset0.substr(offset0.length - 2, 1) + "</span>" +
"<span class='hlred'>" + offset0.substr(offset0.length - 1) + "</span>";
} else {
static_section = offset0;
offset0 = "<span data-toggle='tooltip' data-placement='top' title='" +
Utils.from_base64(static_section, alphabet) + "'>" +
Utils.escape_html(Utils.from_base64(static_section, alphabet)) + "'>" +
static_section + "</span>";
}
@ -245,21 +245,21 @@ var Base64 = {
if (len1 % 4 == 2) {
static_section = offset1.slice(0, -3);
offset1 = padding + "<span data-toggle='tooltip' data-placement='top' title='" +
Utils.from_base64("AA" + static_section, alphabet).slice(1, -2) + "'>" +
Utils.escape_html(Utils.from_base64("AA" + static_section, alphabet).slice(1, -2)) + "'>" +
static_section + "</span>" +
"<span class='hlgreen'>" + offset1.substr(offset1.length - 3, 1) + "</span>" +
"<span class='hlred'>" + offset1.substr(offset1.length - 2) + "</span>";
} else if (len1 % 4 == 3) {
static_section = offset1.slice(0, -2);
offset1 = padding + "<span data-toggle='tooltip' data-placement='top' title='" +
Utils.from_base64("AA" + static_section, alphabet).slice(1, -1) + "'>" +
Utils.escape_html(Utils.from_base64("AA" + static_section, alphabet).slice(1, -1)) + "'>" +
static_section + "</span>" +
"<span class='hlgreen'>" + offset1.substr(offset1.length - 2, 1) + "</span>" +
"<span class='hlred'>" + offset1.substr(offset1.length - 1) + "</span>";
} else {
static_section = offset1;
offset1 = padding + "<span data-toggle='tooltip' data-placement='top' title='" +
Utils.from_base64("AA" + static_section, alphabet).slice(1) + "'>" +
Utils.escape_html(Utils.from_base64("AA" + static_section, alphabet).slice(1)) + "'>" +
static_section + "</span>";
}
@ -274,21 +274,21 @@ var Base64 = {
if (len2 % 4 == 2) {
static_section = offset2.slice(0, -3);
offset2 = padding + "<span data-toggle='tooltip' data-placement='top' title='" +
Utils.from_base64("AAA" + static_section, alphabet).slice(2, -2) + "'>" +
Utils.escape_html(Utils.from_base64("AAA" + static_section, alphabet).slice(2, -2)) + "'>" +
static_section + "</span>" +
"<span class='hlgreen'>" + offset2.substr(offset2.length - 3, 1) + "</span>" +
"<span class='hlred'>" + offset2.substr(offset2.length - 2) + "</span>";
} else if (len2 % 4 == 3) {
static_section = offset2.slice(0, -2);
offset2 = padding + "<span data-toggle='tooltip' data-placement='top' title='" +
Utils.from_base64("AAA" + static_section, alphabet).slice(2, -2) + "'>" +
Utils.escape_html(Utils.from_base64("AAA" + static_section, alphabet).slice(2, -2)) + "'>" +
static_section + "</span>" +
"<span class='hlgreen'>" + offset2.substr(offset2.length - 2, 1) + "</span>" +
"<span class='hlred'>" + offset2.substr(offset2.length - 1) + "</span>";
} else {
static_section = offset2;
offset2 = padding + "<span data-toggle='tooltip' data-placement='top' title='" +
Utils.from_base64("AAA" + static_section, alphabet).slice(2) + "'>" +
Utils.escape_html(Utils.from_base64("AAA" + static_section, alphabet).slice(2)) + "'>" +
static_section + "</span>";
}

View file

@ -19,10 +19,10 @@ var BitwiseOp = {
* @param {byte_array} key
* @param {function} func - The bitwise calculation to carry out
* @param {boolean} null_preserving
* @param {boolean} differential
* @param {string} scheme
* @returns {byte_array}
*/
_bit_op: function (input, key, func, null_preserving, differential) {
_bit_op: function (input, key, func, null_preserving, scheme) {
if (!key || !key.length) key = [0];
var result = [],
x = null,
@ -34,8 +34,15 @@ var BitwiseOp = {
o = input[i];
x = null_preserving && (o === 0 || o == k) ? o : func(o, k);
result.push(x);
if (differential && !(null_preserving && (o === 0 || o == k))) {
key[i % key.length] = x;
if (scheme != "Standard" && !(null_preserving && (o === 0 || o == k))) {
switch (scheme) {
case "Input differential":
key[i % key.length] = x;
break;
case "Output differential":
key[i % key.length] = o;
break;
}
}
}
@ -52,7 +59,7 @@ var BitwiseOp = {
* @constant
* @default
*/
XOR_DIFFERENTIAL: false,
XOR_SCHEME: ["Standard", "Input differential", "Output differential"],
/**
* @constant
* @default
@ -68,12 +75,12 @@ var BitwiseOp = {
*/
run_xor: function (input, args) {
var key = Utils.format[args[0].option].parse(args[0].string || ""),
null_preserving = args[1],
differential = args[2];
scheme = args[1],
null_preserving = args[2];
key = Utils.word_array_to_byte_array(key);
return BitwiseOp._bit_op(input, key, BitwiseOp._xor, null_preserving, differential);
return BitwiseOp._bit_op(input, key, BitwiseOp._xor, null_preserving, scheme);
},

View file

@ -64,6 +64,7 @@ var Code = {
*/
run_json_beautify: function(input, args) {
var indent_str = args[0];
if (!input) return "";
return vkbeautify.json(input, indent_str);
},
@ -121,6 +122,7 @@ var Code = {
* @returns {string}
*/
run_json_minify: function(input, args) {
if (!input) return "";
return vkbeautify.jsonmin(input);
},

View file

@ -279,8 +279,8 @@ HTMLApp.prototype.valid_favourites = function(favourites) {
if (this.operations.hasOwnProperty(favourites[i])) {
valid_favs.push(favourites[i]);
} else {
this.alert("The operation \"" + favourites[i] + "\" is no longer " +
"available. It has been removed from your favourites.", "info");
this.alert("The operation \"" + Utils.escape_html(favourites[i]) +
"\" is no longer available. It has been removed from your favourites.", "info");
}
}
return valid_favs;