mirror of
https://github.com/gchq/CyberChef
synced 2025-12-05 23:53:27 +00:00
Add treat space as plus URLDecode option
This commit is contained in:
@@ -23,7 +23,13 @@ class URLDecode extends Operation {
|
|||||||
this.infoURL = "https://wikipedia.org/wiki/Percent-encoding";
|
this.infoURL = "https://wikipedia.org/wiki/Percent-encoding";
|
||||||
this.inputType = "string";
|
this.inputType = "string";
|
||||||
this.outputType = "string";
|
this.outputType = "string";
|
||||||
this.args = [];
|
this.args = [
|
||||||
|
{
|
||||||
|
"name": "Treat \"+\" as space",
|
||||||
|
"type": "boolean",
|
||||||
|
"value": true
|
||||||
|
},
|
||||||
|
];
|
||||||
this.checks = [
|
this.checks = [
|
||||||
{
|
{
|
||||||
pattern: ".*(?:%[\\da-f]{2}.*){4}",
|
pattern: ".*(?:%[\\da-f]{2}.*){4}",
|
||||||
@@ -39,7 +45,8 @@ class URLDecode extends Operation {
|
|||||||
* @returns {string}
|
* @returns {string}
|
||||||
*/
|
*/
|
||||||
run(input, args) {
|
run(input, args) {
|
||||||
const data = input.replace(/\+/g, "%20");
|
const plusIsSpace = args[0];
|
||||||
|
const data = plusIsSpace ? input.replace(/\+/g, "%20") : input;
|
||||||
try {
|
try {
|
||||||
return decodeURIComponent(data);
|
return decodeURIComponent(data);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
|||||||
Reference in New Issue
Block a user