Merge branch 'insense' of https://github.com/masq/CyberChef into masq-insense
commit
c5270d75a1
|
@ -189,6 +189,8 @@
|
||||||
"Remove null bytes",
|
"Remove null bytes",
|
||||||
"To Upper case",
|
"To Upper case",
|
||||||
"To Lower case",
|
"To Lower case",
|
||||||
|
"To Case Insensitive Regex",
|
||||||
|
"From Case Insensitive Regex",
|
||||||
"Add line numbers",
|
"Add line numbers",
|
||||||
"Remove line numbers",
|
"Remove line numbers",
|
||||||
"To Table",
|
"To Table",
|
||||||
|
|
|
@ -0,0 +1,39 @@
|
||||||
|
/**
|
||||||
|
* @author masq [github.cyberchef@masq.cc]
|
||||||
|
* @copyright Crown Copyright 2018
|
||||||
|
* @license Apache-2.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
import Operation from "../Operation";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* From Case Insensitive Regex operation
|
||||||
|
*/
|
||||||
|
class FromCaseInsensitiveRegex extends Operation {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* FromCaseInsensitiveRegex constructor
|
||||||
|
*/
|
||||||
|
constructor() {
|
||||||
|
super();
|
||||||
|
|
||||||
|
this.name = "From Case Insensitive Regex";
|
||||||
|
this.module = "Default";
|
||||||
|
this.description = "Converts a case-insensitive regex string to a case sensitive regex string (no guarantee on it being the proper original casing) in case /i wasn't available at the time but now is, or you need it to be case-sensitive again.";
|
||||||
|
this.infoURL = "https://wikipedia.org/wiki/Regular_expression";
|
||||||
|
this.inputType = "string";
|
||||||
|
this.outputType = "string";
|
||||||
|
this.args = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {string} input
|
||||||
|
* @param {Object[]} args
|
||||||
|
* @returns {string}
|
||||||
|
*/
|
||||||
|
run(input, args) {
|
||||||
|
return input.replace(/\[[a-z]{2}\]/ig, m => m[1].toUpperCase() === m[2].toUpperCase() ? m[1] : m);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default FromCaseInsensitiveRegex;
|
|
@ -0,0 +1,39 @@
|
||||||
|
/**
|
||||||
|
* @author masq [github.cyberchef@masq.cc]
|
||||||
|
* @copyright Crown Copyright 2018
|
||||||
|
* @license Apache-2.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
import Operation from "../Operation";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* To Case Insensitive Regex operation
|
||||||
|
*/
|
||||||
|
class ToCaseInsensitiveRegex extends Operation {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ToCaseInsensitiveRegex constructor
|
||||||
|
*/
|
||||||
|
constructor() {
|
||||||
|
super();
|
||||||
|
|
||||||
|
this.name = "To Case Insensitive Regex";
|
||||||
|
this.module = "Default";
|
||||||
|
this.description = "Converts a case-sensitive regex string into a case-insensitive regex string in case /i flag is unavailable to you.";
|
||||||
|
this.infoURL = "https://wikipedia.org/wiki/Regular_expression";
|
||||||
|
this.inputType = "string";
|
||||||
|
this.outputType = "string";
|
||||||
|
this.args = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {string} input
|
||||||
|
* @param {Object[]} args
|
||||||
|
* @returns {string}
|
||||||
|
*/
|
||||||
|
run(input, args) {
|
||||||
|
return input.replace(/[a-z]/ig, m => `[${m.toLowerCase()}${m.toUpperCase()}]`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default ToCaseInsensitiveRegex;
|
|
@ -82,6 +82,7 @@ import "./tests/TranslateDateTimeFormat";
|
||||||
import "./tests/Magic";
|
import "./tests/Magic";
|
||||||
import "./tests/ParseTLV";
|
import "./tests/ParseTLV";
|
||||||
import "./tests/Media";
|
import "./tests/Media";
|
||||||
|
import "./tests/ToFromInsensitiveRegex";
|
||||||
|
|
||||||
// Cannot test operations that use the File type yet
|
// Cannot test operations that use the File type yet
|
||||||
//import "./tests/SplitColourChannels";
|
//import "./tests/SplitColourChannels";
|
||||||
|
|
|
@ -0,0 +1,56 @@
|
||||||
|
/**
|
||||||
|
* To/From Case Insensitive Regex tests.
|
||||||
|
*
|
||||||
|
* @author masq [github.cyberchef@masq.cc]
|
||||||
|
*
|
||||||
|
* @copyright Crown Copyright 2018
|
||||||
|
* @license Apache-2.0
|
||||||
|
*/
|
||||||
|
import TestRegister from "../TestRegister";
|
||||||
|
|
||||||
|
TestRegister.addTests([
|
||||||
|
{
|
||||||
|
name: "To Case Insensitive Regex: nothing",
|
||||||
|
input: "",
|
||||||
|
expectedOutput: "",
|
||||||
|
recipeConfig: [
|
||||||
|
{
|
||||||
|
op: "To Case Insensitive Regex",
|
||||||
|
args: [],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "From Case Insensitive Regex: nothing",
|
||||||
|
input: "",
|
||||||
|
expectedOutput: "",
|
||||||
|
recipeConfig: [
|
||||||
|
{
|
||||||
|
op: "From Case Insensitive Regex",
|
||||||
|
args: [],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "To Case Insensitive Regex: simple test",
|
||||||
|
input: "S0meth!ng",
|
||||||
|
expectedOutput: "[sS]0[mM][eE][tT][hH]![nN][gG]",
|
||||||
|
recipeConfig: [
|
||||||
|
{
|
||||||
|
op: "To Case Insensitive Regex",
|
||||||
|
args: [],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "From Case Insensitive Regex: simple test",
|
||||||
|
input: "[sS]0[mM][eE][tT][hH]![nN][Gg] [wr][On][g]?",
|
||||||
|
expectedOutput: "s0meth!nG [wr][On][g]?",
|
||||||
|
recipeConfig: [
|
||||||
|
{
|
||||||
|
op: "From Case Insensitive Regex",
|
||||||
|
args: [],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
]);
|
Loading…
Reference in New Issue