var: add a '64dec' function that can base64 decode a string

Verified in test 455 and 487.

If the provided string cannot be base64-decoded, it will instead use
"[64dec-fail]" (without the quotes).

Documented

Ref: #16288
Closes #16330
This commit is contained in:
Daniel Stenberg 2025-02-22 10:49:19 +01:00
parent 54c07fd6c5
commit a6e8ead533
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
6 changed files with 101 additions and 11 deletions

View file

@ -66,30 +66,45 @@ error.
Available functions:
## trim
## `trim`
removes all leading and trailing white space.
Example:
curl --expand-url https://example.com/{{var:trim}}
## json
## `json`
outputs the content using JSON string quoting rules.
Example:
curl --expand-data {{data:json}} https://example.com
## url
## `url`
shows the content URL (percent) encoded.
Example:
curl --expand-url https://example.com/{{path:url}}
## b64
## `b64`
expands the variable base64 encoded
Example:
curl --expand-url https://example.com/{{var:b64}}
## `64dec`
decodes a base64 encoded character sequence. If the sequence is not possible
to decode, it instead outputs `[64dec-fail]`
Example:
curl --expand-url https://example.com/{{var:64dec}}
(Added in 8.13.0)