Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
How do I protect string?
  • Is the only way is to use Security::xss_clean function? Is there way to make FuelPhp deal alone or automatically with strings like "gwagwaagwghg1515511"?
  • What is wrong with that string? Looks like a fine string to me?

    Perhaps you should start by explaining or describing exactly what you want?
  • "<script>alert();</script>"
    How to protect string from every attack available on the web or most of them?
  • What is the meaning of this in config.php?
    WARNING: Using xss_clean will cause a performance hit.
    How much is dependant on how much input data there is.
  • When do I use Security::xss_clean?
  • I have seen that there are more functions on - http://fuelphp.com/docs/classes/security.html
  • HarroHarro
    Accepted Answer
    Have you tried it?

    Unlike many (if not all) other frameworks, FuelPHP doesn't strip on input, it encodes on output. The main reasoning behind this is that all stripping makes you lose input data.

    Just create a view that contains:

    <h1><?php echo $value; ?></h1>

    And a controller that contains

    public function action_index()
    {
        return View::forge('yourview')->set('value', '<script>alert("this will not popup");</script>');
    }

    and you will see it will not lead to security issues(if it does you have changed the wrong things in the config).

    xss_clean is done through Htmlawed, and is a CPU intensive process. Depending on the amount of data posted, it might cause quite a performance hit. This is why the warning is in the config file.

    In all the applications we have built for our clients, xss_clean was never genericly used. We only use it in cases where an enduser is allowed to enter HTML that has to be passed to the view unencoded. In this case we use a custom config to strip all HTML (and javascript) that is not allowed.
  • You was very clear. Thank you.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion