mirror of
https://github.com/gchq/CyberChef.git
synced 2025-04-21 07:16:17 -04:00
Threshold for treating output as a file is now configurable
This commit is contained in:
parent
e81122739b
commit
caf794b01d
3 changed files with 24 additions and 18 deletions
|
@ -78,8 +78,9 @@ Chef.prototype.bake = async function(input, recipeConfig, options, progress, ste
|
||||||
|
|
||||||
// Depending on the size of the output, we may send it back as a string or an ArrayBuffer.
|
// Depending on the size of the output, we may send it back as a string or an ArrayBuffer.
|
||||||
// This can prevent unnecessary casting as an ArrayBuffer can be easily downloaded as a file.
|
// This can prevent unnecessary casting as an ArrayBuffer can be easily downloaded as a file.
|
||||||
// 1048576 bytes = 1 MiB
|
// The threshold is specified in KiB.
|
||||||
const returnType = this.dish.size() > 1048576 ? Dish.ARRAY_BUFFER : Dish.STRING;
|
const threshold = (options.outputFileThreshold || 1024) * 1024;
|
||||||
|
const returnType = this.dish.size() > threshold ? Dish.ARRAY_BUFFER : Dish.STRING;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
result: this.dish.type === Dish.HTML ?
|
result: this.dish.type === Dish.HTML ?
|
||||||
|
|
|
@ -342,31 +342,35 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="option-item">
|
<div class="option-item">
|
||||||
<input type="checkbox" option="updateUrl" id="updateUrl" checked />
|
<input type="checkbox" option="updateUrl" id="updateUrl" checked />
|
||||||
<label for="updateUrl"> Update the URL when the input or recipe changes </label>
|
<label for="updateUrl"> Update the URL when the input or recipe changes</label>
|
||||||
</div>
|
</div>
|
||||||
<div class="option-item">
|
<div class="option-item">
|
||||||
<input type="checkbox" option="showHighlighter" id="showHighlighter" checked />
|
<input type="checkbox" option="showHighlighter" id="showHighlighter" checked />
|
||||||
<label for="showHighlighter"> Highlight selected bytes in output and input (when possible) </label>
|
<label for="showHighlighter"> Highlight selected bytes in output and input (when possible)</label>
|
||||||
</div>
|
</div>
|
||||||
<div class="option-item">
|
<div class="option-item">
|
||||||
<input type="checkbox" option="treatAsUtf8" id="treatAsUtf8" checked />
|
<input type="checkbox" option="treatAsUtf8" id="treatAsUtf8" checked />
|
||||||
<label for="treatAsUtf8"> Treat output as UTF-8 if possible </label>
|
<label for="treatAsUtf8"> Treat output as UTF-8 if possible</label>
|
||||||
</div>
|
</div>
|
||||||
<div class="option-item">
|
<div class="option-item">
|
||||||
<input type="checkbox" option="wordWrap" id="wordWrap" checked />
|
<input type="checkbox" option="wordWrap" id="wordWrap" checked />
|
||||||
<label for="wordWrap"> Word wrap the input and output </label>
|
<label for="wordWrap"> Word wrap the input and output</label>
|
||||||
</div>
|
</div>
|
||||||
<div class="option-item">
|
<div class="option-item">
|
||||||
<input type="checkbox" option="showErrors" id="showErrors" checked />
|
<input type="checkbox" option="showErrors" id="showErrors" checked />
|
||||||
<label for="showErrors"> Operation error reporting (recommended) </label>
|
<label for="showErrors"> Operation error reporting (recommended)</label>
|
||||||
</div>
|
</div>
|
||||||
<div class="option-item">
|
<div class="option-item">
|
||||||
<input type="checkbox" option="useMetaKey" id="useMetaKey" />
|
<input type="checkbox" option="useMetaKey" id="useMetaKey" />
|
||||||
<label for="useMetaKey"> Use meta key for keybindings (Windows ⊞/Command ⌘) </label>
|
<label for="useMetaKey"> Use meta key for keybindings (Windows ⊞/Command ⌘)</label>
|
||||||
</div>
|
</div>
|
||||||
<div class="option-item">
|
<div class="option-item">
|
||||||
<input type="number" option="errorTimeout" id="errorTimeout" />
|
<input type="number" option="errorTimeout" id="errorTimeout" />
|
||||||
<label for="errorTimeout"> Operation error timeout in ms (0 for never) </label>
|
<label for="errorTimeout"> Operation error timeout in ms (0 for never)</label>
|
||||||
|
</div>
|
||||||
|
<div class="option-item">
|
||||||
|
<input type="number" option="outputFileThreshold" id="outputFileThreshold" />
|
||||||
|
<label for="outputFileThreshold"> Size threshold for treating the output as a file (KiB)</label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
|
|
|
@ -38,15 +38,16 @@ function main() {
|
||||||
];
|
];
|
||||||
|
|
||||||
const defaultOptions = {
|
const defaultOptions = {
|
||||||
updateUrl: true,
|
updateUrl: true,
|
||||||
showHighlighter: true,
|
showHighlighter: true,
|
||||||
treatAsUtf8: true,
|
treatAsUtf8: true,
|
||||||
wordWrap: true,
|
wordWrap: true,
|
||||||
showErrors: true,
|
showErrors: true,
|
||||||
errorTimeout: 4000,
|
errorTimeout: 4000,
|
||||||
attemptHighlight: true,
|
attemptHighlight: true,
|
||||||
theme: "classic",
|
theme: "classic",
|
||||||
useMetaKey: false
|
useMetaKey: false,
|
||||||
|
outputFileThreshold: 1024
|
||||||
};
|
};
|
||||||
|
|
||||||
document.removeEventListener("DOMContentLoaded", main, false);
|
document.removeEventListener("DOMContentLoaded", main, false);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue