<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:series="http://unfoldingneurons.com/"
		>
<channel>
	<title>Comments on: FIEO: Filtering Input with PHP&#8217;s Filter Functions</title>
	<atom:link href="http://www.brandonsavage.net/fieo-filtering-input-with-phps-filter-functions/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.brandonsavage.net/fieo-filtering-input-with-phps-filter-functions/</link>
	<description>The personal blog of Brandon Savage. Contains entries of a personal and professional nature focusing on PHP, Apple, LAMP, MySQL and Washington, DC.</description>
	<lastBuildDate>Thu, 29 Jul 2010 11:09:38 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
	<item>
		<title>By: Paul</title>
		<link>http://www.brandonsavage.net/fieo-filtering-input-with-phps-filter-functions/#comment-1204</link>
		<dc:creator>Paul</dc:creator>
		<pubDate>Fri, 18 Sep 2009 14:37:12 +0000</pubDate>
		<guid isPermaLink="false">http://www.brandonsavage.net/?p=607#comment-1204</guid>
		<description>I find the syntax of the filter ext to be a little... well ugly. Who wants to remember all those constant names? So in my case I wrote a wrapper class around the extension with method names like sanitizeString, validateEmail, etc... which is easier for me to remember.

I also find HTML Purifier to be too big.</description>
		<content:encoded><![CDATA[<p>I find the syntax of the filter ext to be a little&#8230; well ugly. Who wants to remember all those constant names? So in my case I wrote a wrapper class around the extension with method names like sanitizeString, validateEmail, etc&#8230; which is easier for me to remember.</p>
<p>I also find HTML Purifier to be too big.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Les</title>
		<link>http://www.brandonsavage.net/fieo-filtering-input-with-phps-filter-functions/#comment-1089</link>
		<dc:creator>Les</dc:creator>
		<pubDate>Sun, 06 Sep 2009 22:57:57 +0000</pubDate>
		<guid isPermaLink="false">http://www.brandonsavage.net/?p=607#comment-1089</guid>
		<description>I agree HTML Purifier does an excellent job but in my opinion not at the cost of performance.

To get around any security issues what I do is to encode the POSTed data (coming from TEXTAREAs) with base64 and leave it to a human to clean up any mess etc.

Not a perfect solution (you can&#039;t sort or search data) by any means but it ain&#039;t going to 1) break your box and 2) piss off your host.</description>
		<content:encoded><![CDATA[<p>I agree HTML Purifier does an excellent job but in my opinion not at the cost of performance.</p>
<p>To get around any security issues what I do is to encode the POSTed data (coming from TEXTAREAs) with base64 and leave it to a human to clean up any mess etc.</p>
<p>Not a perfect solution (you can&#8217;t sort or search data) by any means but it ain&#8217;t going to 1) break your box and 2) piss off your host.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andy Walpole</title>
		<link>http://www.brandonsavage.net/fieo-filtering-input-with-phps-filter-functions/#comment-1082</link>
		<dc:creator>Andy Walpole</dc:creator>
		<pubDate>Fri, 04 Sep 2009 20:20:35 +0000</pubDate>
		<guid isPermaLink="false">http://www.brandonsavage.net/?p=607#comment-1082</guid>
		<description>The biggest attraction for HTML Purifier is that it works at one of the most critical jobs in an application, namely it stops malicious code - http://htmlpurifier.org/comparison

I don&#039;t have any confidence in the PHP filters for this job and I&#039;m not really sure I want to start experimenting with my own filter for such a crucial job when a tried and tested script is already out there.</description>
		<content:encoded><![CDATA[<p>The biggest attraction for HTML Purifier is that it works at one of the most critical jobs in an application, namely it stops malicious code &#8211; <a href="http://htmlpurifier.org/comparison" rel="nofollow">http://htmlpurifier.org/comparison</a></p>
<p>I don&#8217;t have any confidence in the PHP filters for this job and I&#8217;m not really sure I want to start experimenting with my own filter for such a crucial job when a tried and tested script is already out there.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Brandon Savage</title>
		<link>http://www.brandonsavage.net/fieo-filtering-input-with-phps-filter-functions/#comment-1081</link>
		<dc:creator>Brandon Savage</dc:creator>
		<pubDate>Fri, 04 Sep 2009 20:04:44 +0000</pubDate>
		<guid isPermaLink="false">http://www.brandonsavage.net/?p=607#comment-1081</guid>
		<description>You&#039;ll still face some issues with performance, though they won&#039;t be as bad.

Every time you invoke the PHP parser, APC will stat() the files included (and the files included by that script and so on) to see if they&#039;ve changed. Chances are good that they haven&#039;t, but APC still has to check (unless you disable that functionality as I&#039;ve described here: http://www.brandonsavage.net/to-stat-or-not-to-stat/)

Additionally, as APC fills up, it will dump files off the memory to ensure it doesn&#039;t overrun its limit. This might mean that some files get cached, then dumped, then cached again, etc.

You might be able to solve this by writing an autoload function (see http://us3.php.net/manual/en/function.spl-autoload-register.php and http://www.brandonsavage.net/making-life-better-with-the-spl-autoloader/) but as soon as you hit the HTML Purifier script it will include what it&#039;s been written to include unless you strip out the includes, which would make upgrading difficult.

I think a lot of the time you don&#039;t need the functionality of something as robust as HTML Purifier, and leaving it out is better than including it and then trying to manage the performance and/or access questions that arise. You only need it in select circumstances (namely, when saving input to the database or getting it from the database) so you might be better off using the Lite version, rolling your own, using the filtering functions, or including it ONLY when ABSOLUTELY necessary.</description>
		<content:encoded><![CDATA[<p>You&#8217;ll still face some issues with performance, though they won&#8217;t be as bad.</p>
<p>Every time you invoke the PHP parser, APC will stat() the files included (and the files included by that script and so on) to see if they&#8217;ve changed. Chances are good that they haven&#8217;t, but APC still has to check (unless you disable that functionality as I&#8217;ve described here: <a href="http://www.brandonsavage.net/to-stat-or-not-to-stat/)" rel="nofollow">http://www.brandonsavage.net/to-stat-or-not-to-stat/)</a></p>
<p>Additionally, as APC fills up, it will dump files off the memory to ensure it doesn&#8217;t overrun its limit. This might mean that some files get cached, then dumped, then cached again, etc.</p>
<p>You might be able to solve this by writing an autoload function (see <a href="http://us3.php.net/manual/en/function.spl-autoload-register.php" rel="nofollow">http://us3.php.net/manual/en/function.spl-autoload-register.php</a> and <a href="http://www.brandonsavage.net/making-life-better-with-the-spl-autoloader/)" rel="nofollow">http://www.brandonsavage.net/making-life-better-with-the-spl-autoloader/)</a> but as soon as you hit the HTML Purifier script it will include what it&#8217;s been written to include unless you strip out the includes, which would make upgrading difficult.</p>
<p>I think a lot of the time you don&#8217;t need the functionality of something as robust as HTML Purifier, and leaving it out is better than including it and then trying to manage the performance and/or access questions that arise. You only need it in select circumstances (namely, when saving input to the database or getting it from the database) so you might be better off using the Lite version, rolling your own, using the filtering functions, or including it ONLY when ABSOLUTELY necessary.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mikael</title>
		<link>http://www.brandonsavage.net/fieo-filtering-input-with-phps-filter-functions/#comment-1080</link>
		<dc:creator>Mikael</dc:creator>
		<pubDate>Fri, 04 Sep 2009 19:00:44 +0000</pubDate>
		<guid isPermaLink="false">http://www.brandonsavage.net/?p=607#comment-1080</guid>
		<description>In that case, you just slap APC on the server, don&#039;t you ?</description>
		<content:encoded><![CDATA[<p>In that case, you just slap APC on the server, don&#8217;t you ?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Brandon Savage</title>
		<link>http://www.brandonsavage.net/fieo-filtering-input-with-phps-filter-functions/#comment-1079</link>
		<dc:creator>Brandon Savage</dc:creator>
		<pubDate>Fri, 04 Sep 2009 17:52:11 +0000</pubDate>
		<guid isPermaLink="false">http://www.brandonsavage.net/?p=607#comment-1079</guid>
		<description>Even including the HTML Purifier code through the require() or include() statement has a performance hit, because the compiler must still compile it. So its heft might still present a problem, even if your users don&#039;t actually make use of the code. Something to keep in mind.</description>
		<content:encoded><![CDATA[<p>Even including the HTML Purifier code through the require() or include() statement has a performance hit, because the compiler must still compile it. So its heft might still present a problem, even if your users don&#8217;t actually make use of the code. Something to keep in mind.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mikael</title>
		<link>http://www.brandonsavage.net/fieo-filtering-input-with-phps-filter-functions/#comment-1078</link>
		<dc:creator>Mikael</dc:creator>
		<pubDate>Fri, 04 Sep 2009 08:58:17 +0000</pubDate>
		<guid isPermaLink="false">http://www.brandonsavage.net/?p=607#comment-1078</guid>
		<description>I have started using HTMLPurifier on a project I&#039;m working on and yes it&#039;s heavy. I don&#039;t plan on people POSTing stuff too much, so I&#039;m not too worried about overhead.

However, I would like to hear suggestions of other libraries that I could use, should I find out HTMLPurifier takes up too many resources.

Thanks,

Mikael</description>
		<content:encoded><![CDATA[<p>I have started using HTMLPurifier on a project I&#8217;m working on and yes it&#8217;s heavy. I don&#8217;t plan on people POSTing stuff too much, so I&#8217;m not too worried about overhead.</p>
<p>However, I would like to hear suggestions of other libraries that I could use, should I find out HTMLPurifier takes up too many resources.</p>
<p>Thanks,</p>
<p>Mikael</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: artur ejsmont</title>
		<link>http://www.brandonsavage.net/fieo-filtering-input-with-phps-filter-functions/#comment-1049</link>
		<dc:creator>artur ejsmont</dc:creator>
		<pubDate>Mon, 31 Aug 2009 08:31:12 +0000</pubDate>
		<guid isPermaLink="false">http://www.brandonsavage.net/?p=607#comment-1049</guid>
		<description>1st of all good point Adrian .... title of this post should say &#039;validating email with PHPs filter function&#039; ;-)

but jokes aside, the only thing that worries me about such innovations (they should be in php for ages) is that it always makes me wonder. How actually good are these functions? 

I love to use open source as i save time but sometimes i just dont know what is in there. 

With email there are all those different encodings of domain names and special chars in non-english languages. Its not that simple any more. Will they be accepted or not? How well unit tested is it? (and i dont mean coverage which does not mean anything in this case!). Why did they not add any information (doc says: &#039;Validates value as e-mail.&#039;)

Finally, what if im not happy with it any more? What if there is bug or just filter is crap? Your approach does not isolate your code. So what i would do is add my own wrapper. If i change my mind i will just replace implementation not ripping entire site again. 

In addition i would add a few simple unit tests to make sure i know what to expect and i can easily replace implementation without major risk or waste of time.

With PHP libs its a bit different story. I can easily lookup whats under the hood thats why i like zend framework so much :-) but reading PHP extensions code is usually much more frustrating. But i sill would wrap whenever possible.

To summarize .... yes its super cool they added it and that people can use it but its totally not cool you dont know what you get ;-)

art</description>
		<content:encoded><![CDATA[<p>1st of all good point Adrian &#8230;. title of this post should say &#8216;validating email with PHPs filter function&#8217; ;-)</p>
<p>but jokes aside, the only thing that worries me about such innovations (they should be in php for ages) is that it always makes me wonder. How actually good are these functions? </p>
<p>I love to use open source as i save time but sometimes i just dont know what is in there. </p>
<p>With email there are all those different encodings of domain names and special chars in non-english languages. Its not that simple any more. Will they be accepted or not? How well unit tested is it? (and i dont mean coverage which does not mean anything in this case!). Why did they not add any information (doc says: &#8216;Validates value as e-mail.&#8217;)</p>
<p>Finally, what if im not happy with it any more? What if there is bug or just filter is crap? Your approach does not isolate your code. So what i would do is add my own wrapper. If i change my mind i will just replace implementation not ripping entire site again. </p>
<p>In addition i would add a few simple unit tests to make sure i know what to expect and i can easily replace implementation without major risk or waste of time.</p>
<p>With PHP libs its a bit different story. I can easily lookup whats under the hood thats why i like zend framework so much :-) but reading PHP extensions code is usually much more frustrating. But i sill would wrap whenever possible.</p>
<p>To summarize &#8230;. yes its super cool they added it and that people can use it but its totally not cool you dont know what you get ;-)</p>
<p>art</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ray Paseur</title>
		<link>http://www.brandonsavage.net/fieo-filtering-input-with-phps-filter-functions/#comment-1040</link>
		<dc:creator>Ray Paseur</dc:creator>
		<pubDate>Sun, 30 Aug 2009 14:14:02 +0000</pubDate>
		<guid isPermaLink="false">http://www.brandonsavage.net/?p=607#comment-1040</guid>
		<description>@Adrian: Yes, both.  See the different types here:
http://us2.php.net/manual/en/filter.filters.php</description>
		<content:encoded><![CDATA[<p>@Adrian: Yes, both.  See the different types here:<br />
<a href="http://us2.php.net/manual/en/filter.filters.php" rel="nofollow">http://us2.php.net/manual/en/filter.filters.php</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Adrian</title>
		<link>http://www.brandonsavage.net/fieo-filtering-input-with-phps-filter-functions/#comment-1037</link>
		<dc:creator>Adrian</dc:creator>
		<pubDate>Sun, 30 Aug 2009 09:01:22 +0000</pubDate>
		<guid isPermaLink="false">http://www.brandonsavage.net/?p=607#comment-1037</guid>
		<description>Isn&#039;t this function more like a validator than a filter?</description>
		<content:encoded><![CDATA[<p>Isn&#8217;t this function more like a validator than a filter?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Les</title>
		<link>http://www.brandonsavage.net/fieo-filtering-input-with-phps-filter-functions/#comment-1029</link>
		<dc:creator>Les</dc:creator>
		<pubDate>Sat, 29 Aug 2009 21:26:08 +0000</pubDate>
		<guid isPermaLink="false">http://www.brandonsavage.net/?p=607#comment-1029</guid>
		<description>&gt; HTML Purifier is almost 4.5 MB alone

I would stay away from HTML Purifier; not because it&#039;s badly developed but as stated, it&#039;s not exactly compact and from my own experience there are perforamce concerns.

I did suggest to the developers that they break it down into more modular, manageable components a while back, giving the end user greater control and flexibility over the level of purification they do.

Also, it&#039;s way over the top for the most applications; I beg to differ that there are [now] better options available.</description>
		<content:encoded><![CDATA[<p>&gt; HTML Purifier is almost 4.5 MB alone</p>
<p>I would stay away from HTML Purifier; not because it&#8217;s badly developed but as stated, it&#8217;s not exactly compact and from my own experience there are perforamce concerns.</p>
<p>I did suggest to the developers that they break it down into more modular, manageable components a while back, giving the end user greater control and flexibility over the level of purification they do.</p>
<p>Also, it&#8217;s way over the top for the most applications; I beg to differ that there are [now] better options available.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Brandon Savage</title>
		<link>http://www.brandonsavage.net/fieo-filtering-input-with-phps-filter-functions/#comment-1028</link>
		<dc:creator>Brandon Savage</dc:creator>
		<pubDate>Sat, 29 Aug 2009 14:51:30 +0000</pubDate>
		<guid isPermaLink="false">http://www.brandonsavage.net/?p=607#comment-1028</guid>
		<description>Lars, you&#039;re welcome. Glad I could help. :-)</description>
		<content:encoded><![CDATA[<p>Lars, you&#8217;re welcome. Glad I could help. :-)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Lars Johansson</title>
		<link>http://www.brandonsavage.net/fieo-filtering-input-with-phps-filter-functions/#comment-1027</link>
		<dc:creator>Lars Johansson</dc:creator>
		<pubDate>Sat, 29 Aug 2009 14:47:15 +0000</pubDate>
		<guid isPermaLink="false">http://www.brandonsavage.net/?p=607#comment-1027</guid>
		<description>Hi Brandon,
Thanks, I just implemented a function parsing mailaddresses using &#039;your&#039; filtering technique. Real nice :)</description>
		<content:encoded><![CDATA[<p>Hi Brandon,<br />
Thanks, I just implemented a function parsing mailaddresses using &#8216;your&#8217; filtering technique. Real nice :)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Keith Casey</title>
		<link>http://www.brandonsavage.net/fieo-filtering-input-with-phps-filter-functions/#comment-1021</link>
		<dc:creator>Keith Casey</dc:creator>
		<pubDate>Fri, 28 Aug 2009 20:00:44 +0000</pubDate>
		<guid isPermaLink="false">http://www.brandonsavage.net/?p=607#comment-1021</guid>
		<description>@Les

Agreed that they should have been added sooner, but personally, I look forward to stripping out some of my (potentially incorrect) code in favor of this.  The speed is there but then it&#039;s one more thing that I don&#039;t have to worry about and I can spend my time on other things.</description>
		<content:encoded><![CDATA[<p>@Les</p>
<p>Agreed that they should have been added sooner, but personally, I look forward to stripping out some of my (potentially incorrect) code in favor of this.  The speed is there but then it&#8217;s one more thing that I don&#8217;t have to worry about and I can spend my time on other things.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Brandon Savage</title>
		<link>http://www.brandonsavage.net/fieo-filtering-input-with-phps-filter-functions/#comment-1019</link>
		<dc:creator>Brandon Savage</dc:creator>
		<pubDate>Fri, 28 Aug 2009 18:00:29 +0000</pubDate>
		<guid isPermaLink="false">http://www.brandonsavage.net/?p=607#comment-1019</guid>
		<description>Herman, I&#039;m not sure I buy the people at HTML Purifier as unbiased sources of information. I&#039;d personally be wary about including 842 items in my application. HTML Purifier is almost 4.5 MB alone.

Les, no need to gut your existing script. This is just one option out of many for securing your application. I agree, the filters should have been included sooner.</description>
		<content:encoded><![CDATA[<p>Herman, I&#8217;m not sure I buy the people at HTML Purifier as unbiased sources of information. I&#8217;d personally be wary about including 842 items in my application. HTML Purifier is almost 4.5 MB alone.</p>
<p>Les, no need to gut your existing script. This is just one option out of many for securing your application. I agree, the filters should have been included sooner.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk (feed is rejected)
Page Caching using apc (user agent is rejected)
Database Caching 44/51 queries in 0.070 seconds using disk
Content Delivery Network via Amazon Web Services: S3: files.brandonsavage.net.s3.amazonaws.com

Served from: www.brandonsavage.net @ 2010-07-31 11:06:23 -->