If all else fails, you could convert the string to base64 and have the page decode the string again to get the real url. I used that method on a test proxy page I made and it worked fine for me.
If you want to check the validity of the function, here's a simple function you could use that I use:
PHP Code:
function is_base64($base64String)
{
return (base64_encode(base64_decode($base64String)) == $base64String);
}