Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The general rule/meme is "Filter Input, Escape Output." Using <code>strip_tags</code> on your input to remove any HTML is a good idea for input filtering, but you should be as strict as possible in what input you allow. For example, if an input parameter is only supposed to be an integer, only accept numeric input and always convert it to an integer before doing <em>anything</em> with it. A well-vetted input filtering library is going to help you a lot here; one that isn't specific to a particular framework is <a href="http://inspekt.org" rel="nofollow noreferrer">Inspekt</a> (which I wrote, so I'm a bit biased).</p> <p>For output, <code>htmlspecialchars</code> <em>should</em> be able to escape XSS attacks, <strong>but only if you pass the correct parameters</strong>. You must pass the quote escaping style <em>and</em> a charset.</p> <p>In general, this <em>should</em> remove XSS attacks:</p> <pre><code>$safer_str = htmlspecialchars($unsafe_str, ENT_QUOTES, 'UTF-8'); </code></pre> <p>Without passing <code>ENT_QUOTES</code> as the second parameter, single-quote chars are not encoded. Additionally, XSS attacks have been demonstrated when the correct charset is not passed (typically UTF-8 will be adequate). <code>htmlspecialchars</code> should <em>always</em> be called with ENT_QUOTES and a charset parameter.</p> <p>Note that PHP 5.2.12 contains a fix for <a href="http://bugs.php.net/bug.php?id=49785" rel="nofollow noreferrer">a multibyte XSS attack</a>.</p> <p>You may find the <a href="http://www.owasp.org/index.php/Category:OWASP_Enterprise_Security_API" rel="nofollow noreferrer">OWASP ESAPI PHP port</a> interesting and useful, although the PHP version is not complete AFAIK.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload