URLDecode

Decodes a URL-encoded string.

URLDecode(urlencodedstring [, charset]) → returns String

Argument Reference for the URLDecode function

urlencodedstring

Required: Yes

charset

Required: No
The character encoding in which the string is encoded. Values:
  • utf-8
  • iso-8859-1
  • windows-1252
  • us-ascii
  • shift_jis
  • iso-2022-jp
  • euc-jp
  • euc-kr
  • big5
  • euc-cn
  • utf-16

Examples sample code invoking the URLDecode function


Simple URLDecode() example

Shows how it takes an input of: %21 and returns: !

URLDecode( "%21")

Expected Result: !


Basic URLDecode() usage

In this example we demonstrate taking a URL encoded message passed on the request context and displaying it decoded.

if( len( rc.msg ) ) {
	writeOutput( encodeForHTML( URLDecode( rc.msg ) ) );
}

URLDecode() in obfuscation

In this example we demonstrate url encoding a password before it is encrypted, and then decoding it after it is decrypted.

pwd = URLEncodedFormat( '$18$f^$XlTe41' );
writeOutput( pwd & ' : ' );
pwd = encrypt( pwd, '7Z8of/gKWpqsx/v6O5yHRKanrXsp93B4xIHV97zf88Q=', 'BLOWFISH/CBC/PKCS5Padding', 'HEX' );
writeOutput( pwd & ' : ' );
decpwd = decrypt( pwd, '7Z8of/gKWpqsx/v6O5yHRKanrXsp93B4xIHV97zf88Q=', 'BLOWFISH/CBC/PKCS5Padding', 'HEX' );
writeOutput( decpwd & ' : ' );
decpwd = URLDecode( decpwd );
writeOutput( decpwd );

Expected Result: %2418%24f%5E%24XlTe41 : <some encrypted value> : %2418%24f%5E%24XlTe41 : $18$f^$XlTe41


URLDecode() usage as a member function

In this example we demonstrate taking a URL encoded message passed on the request context and displaying it decoded using the URLDecode() member function.

if( len( rc.msg ) ) {
	writeOutput( encodeForHTML( rc.msg.urlDecode() ) );
}

Fork me on GitHub