博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
OpenProject 的 Wiki 上传「中文文件名」的文件无法查看
阅读量:6850 次
发布时间:2019-06-26

本文共 2298 字,大约阅读时间需要 7 分钟。

使用 OpenProject 一个月中,团队逐渐开始做任务管理、缺陷管理和工时管理,接下来要将内部文档用 Wiki 管理。

问题描述

我试着在 Wiki 写了份 PRD,文中引用的图片是中文文件名,遇到了两个问题

  • 引用处无法显示

  • 点击文末的链接提示 500 系统错误

错误日志

I, [2015-12-23T12:50:50.886339 #21693]  INFO -- : Started GET "/attachments/37" for 116.226.86.102 at 2015-12-23 12:50:50 +0800I, [2015-12-23T12:50:50.889672 #21693]  INFO -- : Processing by AttachmentsController#download as HTMLI, [2015-12-23T12:50:50.889744 #21693]  INFO -- :   Parameters: {"id"=>"37"}I, [2015-12-23T12:50:50.904787 #21693]  INFO -- : OpenProject User: Jonathan Gu (jonathan.gu@jiaj.com.cn ID: 3 
)I, [2015-12-23T12:50:50.923084 #21693] INFO -- : Completed 500 Internal Server Error in 33ms (ActiveRecord: 19.9ms)F, [2015-12-23T12:50:50.924275 #21693] FATAL -- :URI::InvalidURIError (bad URI(is not URI?): /opt/openproject/files/attachment/file/37/02_分享效果图.png): app/models/attachment.rb:62:in `external_url' app/controllers/attachments_controller.rb:36:in `download' app/middleware/params_parser_with_exclusion.rb:40:in `call'I, [2015-12-23T12:50:58.442689 #21693] INFO -- : Started GET "/attachments/37/02_%e5%88%86%e4%ba%ab%e6%95%88%e6%9e%9c%e5%9b%be.png" for 116.226.86.102 at 2015-12-23 12:50:58 +0800I, [2015-12-23T12:50:58.446375 #21693] INFO -- : Processing by AttachmentsController#download as HTMLI, [2015-12-23T12:50:58.446447 #21693] INFO -- : Parameters: {"id"=>"37", "filename"=>"02_分享效果图.png"}I, [2015-12-23T12:50:58.461368 #21693] INFO -- : OpenProject User: Jonathan Gu (jonathan.gu@jiaj.com.cn ID: 3
)I, [2015-12-23T12:50:58.478570 #21693] INFO -- : Completed 500 Internal Server Error in 32ms (ActiveRecord: 18.4ms)F, [2015-12-23T12:50:58.479710 #21693] FATAL -- :URI::InvalidURIError (bad URI(is not URI?): /opt/openproject/files/attachment/file/37/02_分享效果图.png): app/models/attachment.rb:62:in `external_url' app/controllers/attachments_controller.rb:36:in `download' app/middleware/params_parser_with_exclusion.rb:40:in `call'

解决方案

根据错误提示,找到 app/models/attachement.rb 文件,确保 URI.parse 前使用 URI.escape 转义。

修改前代码

def external_url     url = URI.parse file.download_url # returns a path if local     url if url.host   end

修改后代码

def external_url     escaped_url = URI.escape file.download_url     url = URI.parse escaped_url # returns a path if local      url if url.host   end

参考链接

转载地址:http://wcgul.baihongyu.com/

你可能感兴趣的文章