<?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/"
		>
<channel>
	<title>Comments on: Securing Uploaded Image Files</title>
	<atom:link href="http://www.charles-reace.com/blog/2008/08/05/securing-uploaded-image-files/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.charles-reace.com/blog/2008/08/05/securing-uploaded-image-files/</link>
	<description>Charles Reace&#039;s blog about PHP, MySQL, and life in general</description>
	<lastBuildDate>Mon, 22 Aug 2011 17:18:05 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>By: cwreace</title>
		<link>http://www.charles-reace.com/blog/2008/08/05/securing-uploaded-image-files/comment-page-1/#comment-13</link>
		<dc:creator>cwreace</dc:creator>
		<pubDate>Wed, 20 Aug 2008 05:34:42 +0000</pubDate>
		<guid isPermaLink="false">http://www.charles-reace.com/blog/?p=48#comment-13</guid>
		<description>Good point, Hayley. I guess that needs to factor into one&#039;s decision whether or not to do such &quot;sanitizing&quot;.</description>
		<content:encoded><![CDATA[<p>Good point, Hayley. I guess that needs to factor into one&#8217;s decision whether or not to do such &#8220;sanitizing&#8221;.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Hayley Watson</title>
		<link>http://www.charles-reace.com/blog/2008/08/05/securing-uploaded-image-files/comment-page-1/#comment-12</link>
		<dc:creator>Hayley Watson</dc:creator>
		<pubDate>Tue, 19 Aug 2008 10:45:19 +0000</pubDate>
		<guid isPermaLink="false">http://www.charles-reace.com/blog/?p=48#comment-12</guid>
		<description>That would strip out all other embedded metadata too: JPEG EXIF data, PNG tEXt blocks.</description>
		<content:encoded><![CDATA[<p>That would strip out all other embedded metadata too: JPEG EXIF data, PNG tEXt blocks.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: cwreace</title>
		<link>http://www.charles-reace.com/blog/2008/08/05/securing-uploaded-image-files/comment-page-1/#comment-11</link>
		<dc:creator>cwreace</dc:creator>
		<pubDate>Thu, 07 Aug 2008 01:21:45 +0000</pubDate>
		<guid isPermaLink="false">http://www.charles-reace.com/blog/?p=48#comment-11</guid>
		<description>Hi, Znupi. Thanks for posting your function. I&#039;ll have to take a closer look at it when I get a chance. Ultimately, I&#039;d probably want to combine it with something akin to what I did to further limit the allowed image types, as I may not ultimately want to allow all types that my GD installation supports; but it&#039;s definitely a good idea to ensure that GD supports any image type that I want to allow. :)</description>
		<content:encoded><![CDATA[<p>Hi, Znupi. Thanks for posting your function. I&#8217;ll have to take a closer look at it when I get a chance. Ultimately, I&#8217;d probably want to combine it with something akin to what I did to further limit the allowed image types, as I may not ultimately want to allow all types that my GD installation supports; but it&#8217;s definitely a good idea to ensure that GD supports any image type that I want to allow. :)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Znupi</title>
		<link>http://www.charles-reace.com/blog/2008/08/05/securing-uploaded-image-files/comment-page-1/#comment-10</link>
		<dc:creator>Znupi</dc:creator>
		<pubDate>Tue, 05 Aug 2008 19:20:54 +0000</pubDate>
		<guid isPermaLink="false">http://www.charles-reace.com/blog/?p=48#comment-10</guid>
		<description>Interesting, but I have one thing to say: you shouldn&#039;t just test if the image is a gif, a png or a jpg. You should test if the GD library can actually open it. Here&#039;s a little function I use in order to open images only if they are compatible with the GD version on the server:
&lt;code&gt;
function loadImage($path) {
	if (!file_exists($path)) return false;
	list(,,$imageType) = getImageSize($path);
	if (!(imagetypes() &amp; $imageType)) return false;
	return imageCreateFromString(file_get_contents($path));
}
&lt;/code&gt;
Oh, and why do you use list($unused, $type) when you can simply use list( , $type) ?</description>
		<content:encoded><![CDATA[<p>Interesting, but I have one thing to say: you shouldn&#8217;t just test if the image is a gif, a png or a jpg. You should test if the GD library can actually open it. Here&#8217;s a little function I use in order to open images only if they are compatible with the GD version on the server:<br />
<code><br />
function loadImage($path) {<br />
	if (!file_exists($path)) return false;<br />
	list(,,$imageType) = getImageSize($path);<br />
	if (!(imagetypes() &amp; $imageType)) return false;<br />
	return imageCreateFromString(file_get_contents($path));<br />
}<br />
</code><br />
Oh, and why do you use list($unused, $type) when you can simply use list( , $type) ?</p>
]]></content:encoded>
	</item>
</channel>
</rss>

