mirror of
https://github.com/gchq/CyberChef.git
synced 2025-05-09 15:55:01 -04:00
fixing content-type issue
This commit is contained in:
parent
72111cd2bb
commit
78ba4d4fd3
1 changed files with 51 additions and 61 deletions
|
@ -83,9 +83,14 @@ class Mime {
|
|||
*/
|
||||
_walkMime(parentObj) {
|
||||
let new_line_length = this.rn ? 2 : 1;
|
||||
let contType = null, fileName = null, charEnc = null, contDispoObj = null;
|
||||
let contType = null,
|
||||
fileName = null,
|
||||
charEnc = null,
|
||||
contDispoObj = null,
|
||||
contTypeObj = null;
|
||||
if (parentObj.header.hasOwnProperty("content-type")) {
|
||||
let contTypeObj = Mime._decodeComplexField(parentObj.header["content-type"][0]);
|
||||
contTypeObj = Mime._decodeComplexField(parentObj.header["content-type"][0]);
|
||||
}
|
||||
if (parentObj.header.hasOwnProperty("content-disposition")) {
|
||||
contDispoObj = Mime._decodeComplexField(parentObj.header["content-disposition"][0])
|
||||
if (contDispoObj != null && contDispoObj.hasOwnProperty("filename")) {
|
||||
|
@ -102,6 +107,9 @@ class Mime {
|
|||
if (fileName == null && contTypeObj.hasOwnProperty("name")) {
|
||||
fileName = contTypeObj.name;
|
||||
}
|
||||
} else {
|
||||
contType = "text/plain";
|
||||
charEnc = "us-ascii";
|
||||
}
|
||||
if (contType.startsWith("multipart/")) {
|
||||
let output_sections = [];
|
||||
|
@ -128,8 +136,6 @@ class Mime {
|
|||
}
|
||||
return [{type: contType, data: parentObj.body, name: fileName}];
|
||||
}
|
||||
throw new OperationError("Invalid Mime section");
|
||||
}
|
||||
|
||||
/**
|
||||
* Takes a string and decodes quoted words inside them
|
||||
|
@ -193,22 +199,6 @@ class Mime {
|
|||
break;
|
||||
case "quoted-printable":
|
||||
input = Utils.byteArrayToUtf8(decodeQuotedPrintable(input));
|
||||
break;
|
||||
case "x-uuencode":
|
||||
//TODO: need to trim before and after;
|
||||
let match = /^\s*begin[^\n]+\n(.*)\r?\n`\r?\nend\s*$/gs.exec(input);
|
||||
let lineReg = /\r?\n?.(.*)$/gm;
|
||||
let line = null;
|
||||
let lines = [];
|
||||
while ((line = lineReg.exec(match[1]))) {
|
||||
lines.push(fromBase64(line[1], " -_"));
|
||||
}
|
||||
if (match) {
|
||||
input = lines.join("");
|
||||
} else {
|
||||
throw new OperationError("Invalid uuencoding");
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (charEnc && MIME_FORMAT.hasOwnProperty(charEnc.toLowerCase())) {
|
||||
input = cptable.utils.decode(MIME_FORMAT[charEnc.toLowerCase()], input);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue