读书人

通过redmine repository看代码的一个有

发布时间: 2012-06-30 17:20:12 作者: rapoo

通过redmine repository看代码的一个问题

通过redmine repository看代码,有时候按review按钮,可是浏览器却弹出download画面, 导致不能和看DIFF一样直接在线观看,非常不方便。

?

经过google搜索, 有人回答原因如下。

?

ruby中如果string中有超过30%ascii码或者回车换行符以外的字符的话, 就会被认为是二进制数据,导致不能在网页中直接打开,而显示了Download画面。

?

?

解决方法

?

参照以下DIFF文件

Index: app/controllers/repositories_controller.rb===================================================================--- app/controllers/repositories_controller.rb    (revision 1709)+++ app/controllers/repositories_controller.rb    (working copy)@@ -102,7 +102,7 @@     @content = @repository.cat(@path, @rev)     show_error_not_found and return unless @content-    if 'raw' == params[:format] || @content.is_binary_data?+    if 'raw' == params[:format] || @content.include?("\x00")       # Force the download if it's a binary file       send_data @content, :filename => @path.split('/').last     else 

读书人网 >操作系统

热点推荐