{urldecode:string}

Description

Decodes a URL-encoded (percent-encoded) string back to its original text, the way PHP urldecode does for query strings and HTML form data. Every %XX sequence becomes the byte it stands for: %20 becomes a space, %2F a slash, %3D an equals sign, %26 an ampersand, %25 a percent sign. The one trait that sets it apart from rawurldecode: a literal plus sign is decoded to a SPACE (the application/x-www-form-urlencoded rule), so a real plus must arrive as %2B. Invalid or incomplete sequences such as a lone percent are passed through unchanged. For modern RFC 3986 URLs where a plus must stay a plus, use rawurldecode instead. This command never caches its result and never trims its input.

Parameters

string required

The percent-encoded text to decode. Plus signs are turned into spaces and %XX sequences into their bytes; text with neither is returned unchanged. The input is not trimmed, so leading or trailing spaces are preserved.

Examples

test{urldecode:Praha%201}
ExpectedPraha 1
ActualPraha 1
Decodes %20 to a space. The most common case: a value pulled from a query string.
test{urldecode:Praha+1}
ExpectedPraha 1
ActualPraha 1
The trait that distinguishes urldecode from rawurldecode: a literal plus sign is decoded to a space, because this is form/query encoding. If you need the plus to survive, use rawurldecode.
test{urldecode:q%3D1%26r%3D2}
Expectedq=1&r=2
Actualq=1&r=2
Decodes an escaped query string. %3D is an equals sign, %26 an ampersand, so the value reads back as q=1&r=2.
test{urldecode:novinky%2F2026}
Expectednovinky/2026
Actualnovinky/2026
A path-like value: %2F decodes to a slash.
test{urldecode:1%2B1%3D2}
Expected1+1=2
Actual1+1=2
To keep a real plus sign, it must be encoded as %2B. Here %2B decodes to a plus and %3D to an equals sign, giving 1+1=2. Compare with example 2, where a bare plus turned into a space.
test{urldecode:100%25 hotovo}
Expected100% hotovo
Actual100% hotovo
A percent sign in the source must itself be escaped as %25; it decodes back to a single percent.
test{urldecode:plain text passthrough}
Expectedplain text passthrough
Actualplain text passthrough
A string with no percent sequences and no plus signs is returned unchanged.
test{urldecode:{urlencode:Praha 1}}
ExpectedPraha 1
ActualPraha 1
urldecode is the inverse of urlencode. urlencode turns the space into a plus, then urldecode turns it back into a space, recovering the original value.