From 48f8ca693d66cf1dc08db4821033e4a21820c8f3 Mon Sep 17 00:00:00 2001 From: n1474335 Date: Sun, 14 Jan 2018 18:26:06 +0000 Subject: [PATCH] Added detection patterns for Octal, Binary, Decimal, Hexdumps, HTML Entities, URL encoding, escaped Unicode, and Quoted Printable encoding. --- src/core/config/OperationConfig.js | 193 +++++++++++++++++++++-------- 1 file changed, 138 insertions(+), 55 deletions(-) diff --git a/src/core/config/OperationConfig.js b/src/core/config/OperationConfig.js index b87d25e4..db133069 100755 --- a/src/core/config/OperationConfig.js +++ b/src/core/config/OperationConfig.js @@ -797,12 +797,37 @@ const OperationConfig = { value: ByteRepr.DELIM_OPTIONS } ], - patterns: [ // TODO - //{ - // match: "^$", - // flags: "", - // args: [] - //}, + patterns: [ + { + match: "^(?:[0-7]{1,2}|[123][0-7]{2})(?: (?:[0-7]{1,2}|[123][0-7]{2}))*$", + flags: "", + args: ["Space"] + }, + { + match: "^(?:[0-7]{1,2}|[123][0-7]{2})(?:,(?:[0-7]{1,2}|[123][0-7]{2}))*$", + flags: "", + args: ["Comma"] + }, + { + match: "^(?:[0-7]{1,2}|[123][0-7]{2})(?:;(?:[0-7]{1,2}|[123][0-7]{2}))*$", + flags: "", + args: ["Semi-colon"] + }, + { + match: "^(?:[0-7]{1,2}|[123][0-7]{2})(?::(?:[0-7]{1,2}|[123][0-7]{2}))*$", + flags: "", + args: ["Colon"] + }, + { + match: "^(?:[0-7]{1,2}|[123][0-7]{2})(?:\\n(?:[0-7]{1,2}|[123][0-7]{2}))*$", + flags: "", + args: ["Line feed"] + }, + { + match: "^(?:[0-7]{1,2}|[123][0-7]{2})(?:\\r\\n(?:[0-7]{1,2}|[123][0-7]{2}))*$", + flags: "", + args: ["CRLF"] + }, ] }, "To Octal": { @@ -874,12 +899,42 @@ const OperationConfig = { value: ByteRepr.BIN_DELIM_OPTIONS } ], - patterns: [ // TODO - //{ - // match: "^$", - // flags: "", - // args: [] - //}, + patterns: [ + { + match: "^(?:[01]{8})+$", + flags: "", + args: ["None"] + }, + { + match: "^(?:[01]{8})(?: [01]{8})*$", + flags: "", + args: ["Space"] + }, + { + match: "^(?:[01]{8})(?:,[01]{8})*$", + flags: "", + args: ["Comma"] + }, + { + match: "^(?:[01]{8})(?:;[01]{8})*$", + flags: "", + args: ["Semi-colon"] + }, + { + match: "^(?:[01]{8})(?::[01]{8})*$", + flags: "", + args: ["Colon"] + }, + { + match: "^(?:[01]{8})(?:\\n[01]{8})*$", + flags: "", + args: ["Line feed"] + }, + { + match: "^(?:[01]{8})(?:\\r\\n[01]{8})*$", + flags: "", + args: ["CRLF"] + }, ] }, "To Binary": { @@ -909,12 +964,37 @@ const OperationConfig = { value: ByteRepr.DELIM_OPTIONS } ], - patterns: [ // TODO - //{ - // match: "^$", - // flags: "", - // args: [] - //}, + patterns: [ + { + match: "^(?:\\d{1,2}|1\\d{2}|2[0-4]\\d|25[0-5])(?: (?:\\d{1,2}|1\\d{2}|2[0-4]\\d|25[0-5]))*$", + flags: "", + args: ["Space"] + }, + { + match: "^(?:\\d{1,2}|1\\d{2}|2[0-4]\\d|25[0-5])(?:,(?:\\d{1,2}|1\\d{2}|2[0-4]\\d|25[0-5]))*$", + flags: "", + args: ["Comma"] + }, + { + match: "^(?:\\d{1,2}|1\\d{2}|2[0-4]\\d|25[0-5])(?:;(?:\\d{1,2}|1\\d{2}|2[0-4]\\d|25[0-5]))*$", + flags: "", + args: ["Semi-colon"] + }, + { + match: "^(?:\\d{1,2}|1\\d{2}|2[0-4]\\d|25[0-5])(?::(?:\\d{1,2}|1\\d{2}|2[0-4]\\d|25[0-5]))*$", + flags: "", + args: ["Colon"] + }, + { + match: "^(?:\\d{1,2}|1\\d{2}|2[0-4]\\d|25[0-5])(?:\\n(?:\\d{1,2}|1\\d{2}|2[0-4]\\d|25[0-5]))*$", + flags: "", + args: ["Line feed"] + }, + { + match: "^(?:\\d{1,2}|1\\d{2}|2[0-4]\\d|25[0-5])(?:\\r\\n(?:\\d{1,2}|1\\d{2}|2[0-4]\\d|25[0-5]))*$", + flags: "", + args: ["CRLF"] + }, ] }, "To Decimal": { @@ -938,12 +1018,12 @@ const OperationConfig = { inputType: "string", outputType: "byteArray", args: [], - patterns: [ // TODO - //{ - // match: "^$", - // flags: "", - // args: [] - //}, + patterns: [ + { + match: "^(?:(?:[\\dA-F]{4,16}:?)?\\s*((?:[\\dA-F]{2}\\s){1,8}(?:\\s|[\\dA-F]{2}-)(?:[\\dA-F]{2}\\s){1,8}|(?:[\\dA-F]{2}\\s|[\\dA-F]{4}\\s)+)[^\\n]*\\n?)+$", + flags: "i", + args: [] + }, ] }, "To Hexdump": { @@ -1003,12 +1083,12 @@ const OperationConfig = { inputType: "string", outputType: "string", args: [], - patterns: [ // TODO - //{ - // match: "^$", - // flags: "", - // args: [] - //}, + patterns: [ + { + match: "&(?:#\\d{2,3}|#x[\\da-f]{2}|[a-z]{2,6});", + flags: "i", + args: [] + }, ] }, "To HTML Entity": { @@ -1053,12 +1133,12 @@ const OperationConfig = { inputType: "string", outputType: "string", args: [], - patterns: [ // TODO - //{ - // match: "^$", - // flags: "", - // args: [] - //}, + patterns: [ + { + match: "%[\\da-f]{2}", + flags: "i", + args: [] + }, ] }, "URL Encode": { @@ -1093,12 +1173,22 @@ const OperationConfig = { value: Unicode.PREFIXES } ], - patterns: [ // TODO - //{ - // match: "^$", - // flags: "", - // args: [] - //}, + patterns: [ + { + match: "\\\\u(?:[\\da-f]{4,6})", + flags: "i", + args: ["\\u"] + }, + { + match: "%u(?:[\\da-f]{4,6})", + flags: "i", + args: ["%u"] + }, + { + match: "U\\+(?:[\\da-f]{4,6})", + flags: "i", + args: ["U+"] + }, ] }, "From Quoted Printable": { @@ -1107,12 +1197,12 @@ const OperationConfig = { inputType: "string", outputType: "byteArray", args: [], - patterns: [ // TODO - //{ - // match: "^$", - // flags: "", - // args: [] - //}, + patterns: [ + { + match: "(?:=[\\da-f]{2}|=\\n)(?:[\\x21-\\x3d\\x3f-\\x7e \\t]|=[\\da-f]{2}|=\\n)*$", + flags: "i", + args: [] + }, ] }, "To Quoted Printable": { @@ -1133,13 +1223,6 @@ const OperationConfig = { type: "boolean", value: Punycode.IDN } - ], - patterns: [ // TODO - //{ - // match: "^$", - // flags: "", - // args: [] - //}, ] }, "To Punycode": {