<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
					xmlns:content="http://purl.org/rss/1.0/modules/content/"
					xmlns:wfw="http://wellformedweb.org/CommentAPI/"
				  >
<channel>
<title><![CDATA[Saturn's Weblog - 标签：bug]]></title>
<link>http://www.cnsaturn.com/tag/bug</link>
<description><![CDATA[Saturn's weblog, STBlog官方站点]]></description>
<language>zh-CN</language>
<pubDate>Thu, 09 Sep 2010 19:23:28 -0400</pubDate>
<item>
<title><![CDATA[CodeIgniter上传类库的一个Bug]]></title>
<link>http://www.cnsaturn.com/posts/a-bug-of-the-upload-class-of-codeingiter</link>
<pubDate>Mon, 14 Sep 2009 12:13:00 -0400</pubDate>
<description><![CDATA[<p>
 这几天重构<a href="/logs/2009/04/14/new_blog_launched">博客程序</a>的时候，发现了一个<a href="http://codeigniter.com/">CodeIgniter</a>默认上传类的BUG。很奇怪的是，一直到前些天CI官方最新发布的1.7.2，此BUG仍未修正，特此记录。</p>
<p>
 <strong>症状</strong>：只能上传图片后缀的文件，其他类型文件（比如.zip,.tar.gz）无法通过验证，就算你将这些类型添加进了$config[&#39;allowed_types&#39;]。</p>
<p>
 <strong>涉及到的CodeIgniter版本</strong>：1.7.1;1.7.2。</p>
<p>
 <strong>原因</strong>：Upload Class中的is_allowed_filetype()方法有逻辑错误。</p>
<p>
 <strong>解决方案</strong>：</p>
<p>
 1、如果你不想动CI的系统源码，那么就将除图片类型之外的其他后缀，放到图片类型之前，比如：</p>
<p>
 $config[&#39;allowed_types&#39;] = &#39;<span style="color: rgb(128, 0, 0);"><strong>zip|gz</strong></span>|png|gif|jpg&#39;;(<span style="color: rgb(0, 0, 255);">正确</span>)</p>
<p>
 $config[&#39;allowed_types&#39;] = &#39;png|gif|jpg|<strong><span style="color: rgb(128, 0, 0);">zip|gz</span></strong>&#39;;(<span style="color: rgb(255, 0, 0);">错误</span>)</p>
<p>
 请注意以上暗红色部分的位置。</p>
<p>
 2、对Upload.php开刀并修改is_allowed_filetype()的判断逻辑，解决办法在这个帖子里面：</p>
<p>
 http://codeigniter.com/forums/viewthread/113029/</p>
<p>
 这个BUG在<a href="http://codeigniter.com/bug_tracker/bug/7291/">BUG Tracker</a>存在了那么久，开发者竟然不采纳的&hellip;&hellip;What can I say?</p>]]></description>
<author><![CDATA[Saturn]]></author>
<guid isPermaLink="true" >http://www.cnsaturn.com/posts/a-bug-of-the-upload-class-of-codeingiter</guid>
</item>
</channel>
</rss>                  