mirror of
https://github.com/gchq/CyberChef
synced 2025-01-12 04:28:53 +00:00
add toggle treating "+" as spaces in URL decode
This commit is contained in:
parent
ba12ad8e7c
commit
2f0da26999
1 changed files with 9 additions and 2 deletions
|
@ -23,7 +23,13 @@ class URLDecode extends Operation {
|
|||
this.infoURL = "https://wikipedia.org/wiki/Percent-encoding";
|
||||
this.inputType = "string";
|
||||
this.outputType = "string";
|
||||
this.args = [];
|
||||
this.args = [
|
||||
{
|
||||
"name": "Treat \"+\" as space",
|
||||
"type": "boolean",
|
||||
"value": false
|
||||
},
|
||||
];
|
||||
this.checks = [
|
||||
{
|
||||
pattern: ".*(?:%[\\da-f]{2}.*){4}",
|
||||
|
@ -39,7 +45,8 @@ class URLDecode extends Operation {
|
|||
* @returns {string}
|
||||
*/
|
||||
run(input, args) {
|
||||
const data = input.replace(/\+/g, "%20");
|
||||
const plusIsSpace = args[0];
|
||||
const data = plusIsSpace ? input.replace(/\+/g, "%20") : input;
|
||||
try {
|
||||
return decodeURIComponent(data);
|
||||
} catch (err) {
|
||||
|
|
Loading…
Reference in a new issue