Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save trycf/a84734506062d6e95a9c77477a37ddf6 to your computer and use it in GitHub Desktop.

Select an option

Save trycf/a84734506062d6e95a9c77477a37ddf6 to your computer and use it in GitHub Desktop.
TryCF Gist
<cfscript>
rc = {
"key0": "hello%252520world87%%20test",
"key1": "hello%252520world",
"key2": "hello%2520world 87%25",
"key2": "hello%2520world 87%"
}
rc.each( (key, value ) => {
if ( !isNull( value ) && isSimpleValue( value ) ) {
try{
rc[key] = urlDecode( urlDecode( rc[key].toString() ) );
} catch( any error ){
dump( "URL_DECODE_WARNING :: Key #key# :: #error.message# :: Manually decoding" );
rc[key] = reReplace( rc[key].toString(), "%(?![0-9A-Fa-f]{2})", "%2525", "all" );
if ( reFind( "%[0-9A-Fa-f]{2}", rc[key] ) ) rc[key] = urlDecode( rc[key] );
rc[key] = reReplace( rc[key], "%(?![0-9A-Fa-f]{2})", "%2525", "all" );
if ( reFind("%[0-9A-Fa-f]{2}", rc[key] ) ) rc[key] = urlDecode( rc[key] );
}
}
} );
dump( rc )
</cfscript>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment