+ Start a Discussion
MattLMattL 

Invalid Page Redirection Error Message

I have a relatively simple S-control that is manifesting some bizarre problems I can't easily reproduce. The only thing I get is a message from Salesforce:
 Invalid Page Redirection
    The page you attempted to access has been blocked due to an outside website or an improperly coded link or button. Please contact your Salesforce Administrator for assistance.

  Click here to return to the previous page.

The only thing I can think of is that there is something wrong with the JS I pulled off the web to process out the retUrl parameter from the URL my S-control is fed.

Code:
//function to decode given URL
function decodeUrl(url)
{
   /* When decoding the URL we will do the following:

           1.) Replace + with ' '
           2.) Replace %xx with equivalent character
           3.) Put [—] in output if %xx is invalid.
   */

   //string holding our hexadecimal values
   var hexValues = "0123456789ABCDEFabcdef"; 
   //value to hold the initial URL value
   //variable to hold the final URL value
   var returnURL = "";
   //counter variable
   var count = 0;
   plainUrl = url;
   //start looping through each character in the URL
   while (count < plainUrl.length) 
   {
      //get each character on each iteration
      var charValue = plainUrl.charAt(count);
      //determine the value of the character
      switch(charValue)
      {
         //if the character is a plus sign (+) then append a space
         case "+":
             returnURL += " ";
             //increment our counter
             count++;
             break;
         //if the character is a percent sign we have a little more work to do
         case "%":
             //first determine if we have a valid character (one that is in our list)
             if (count < (plainUrl.length - 2) && hexValues.indexOf(plainUrl.charAt(count+1)) != -1 && hexValues.indexOf(plainUrl.charAt(count + 2)) != -1 ) 
             {
                 //its a valid character so unescape it
          returnURL += unescape(plainUrl.substr(count,3));
                 //increment the counter by 3
          count += 3;
      } 
             else 
             {
          //we have a bad character so append [–]
          returnURL += "%[˜]";
          count++;
             }
             break;
         default:
             //default value is to append the current character
             //to the return value
             returnURL += charValue;
             count++;
             break;
      }
    }
   //return the final decoded URL
   return returnURL;
}

function gup( name )
{
  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regexS = "[\\™&]"+name+"=([%^&#]*)";
  var regex = new RegExp( regexS );
  var results = regex.exec( decodeUrl(window.parent.location.href) );
  var result = decodeUrl(window.parent.location.href).substr(results.index+8,24);
  if( results == null )
    return "";
  else
    return result;
}


 And the actual call is: window.opener.location.href = "https://na1.salesforce.com/"+gup("retURL");

Best Answer chosen by Admin (Salesforce Developers) 
Ron WildRon Wild

In case anyone is following this thread ... I worked around the problem by twice-encoding the fully qualified URLs being passed in as URL parms and then modifying the visualforce page to twice-decode.

 

Hope 

All Answers

Ron WildRon Wild

I'm getting the same error passing a url-encoded URL as a parameter to a visualforce page:

 

https://na2.salesforce.com/apex/vfpage?id=1234&cancelURL=http%3A%2F%2Fwww.amazon.com

 

Remove the "http" or change "http" to "htt" and the error goes away.

 

Has anyone else seen this?  Figured out how to pass a URL?

 

Thanks,

 

Ron

Ron WildRon Wild

In case anyone is following this thread ... I worked around the problem by twice-encoding the fully qualified URLs being passed in as URL parms and then modifying the visualforce page to twice-decode.

 

Hope 

This was selected as the best answer
N M 17N M 17
@Ron -  How did you sovled this issue?  It will be great if you can explain more ,please. I am also facing the same issue.