Jump to content

Need help to "Sanatize" a URL?


roldahayes

Recommended Posts

Hi, Im trying to sort out a problem with Cross Site Scripting on a basket page we use.

 

We have been told by our security PCI sanning company that the data that needs to be "sanatized" is:

 

// assign variables

    //echo "ref1:" . $HTTP_REFERER . "<br>";

    //$temp = (string)$HTTP_REFERER;

    //$urlref2 = substr($temp,0,6);

    //echo "ref:" . $urlref;

    $urlref = $HTTP_REFERER;

    $prodID = $_GET['productID'];

    $delete = $_GET ['delete'];

    $quantity = $_GET['quantity'];

    $updateQuantity = $_GET['updateQuantity'];

    $update = $_GET ['update'];

    $currency = "£";

    // maximum querys per user basket

    $MAXBASKETQUERY = 25;

    // start the html table  

 

Can anyone suggest the best way to do this please?

Link to comment
Share on other sites

mysql_real_escape _string will sanitize data going into MySQL.

htmlentities will sanitize any data being displayed on screen.

 

Of course any data being submitted to your site should be validated server side too, before ever being displayed or added to your database.

Link to comment
Share on other sites

Thanks,

 

I think the problem is that our basket page displays as:

 

www.domainname.co.uk/basket.php?src=%2Fproduct_page.php&productID=1126538

 

And this is deemed to be the security risk...  is there a way to get it to not display the %2f ??

Link to comment
Share on other sites

Yeah the manual

http://php.net/manual/en/function.mysql-real-escape-string.php

 

$prodID = mysql_real_escape_string($_GET['productID']);

assuming it was alphanumberic. If it was only numeric you could just as easily use

$prodID = intval($_GET['productID']);

 

 

edit: %2F is a / character. Just remove that from /product_page.php somewhere in the code.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.