소스 검색

BugFix: correspond to the situation that attachment is not found

Yuki Takei 7 년 전
부모
커밋
d5e2f03d69
1개의 변경된 파일4개의 추가작업 그리고 0개의 파일을 삭제
  1. 4 0
      src/server/routes/attachment.js

+ 4 - 0
src/server/routes/attachment.js

@@ -35,6 +35,10 @@ module.exports = function(crowi, app) {
    * @param {boolean} forceDownload
    */
   async function responseForAttachment(res, user, attachment, forceDownload) {
+    if (attachment == null) {
+      return res.json(ApiResponse.error('attachment not found'));
+    }
+
     const isAccessible = await isAccessibleByViewer(user, attachment);
     if (!isAccessible) {
       return res.json(ApiResponse.error(`Forbidden to access to the attachment '${attachment.id}'`));