Просмотр исходного кода

BugFix: correspond to the situation that attachment is not found

Yuki Takei 7 лет назад
Родитель
Сommit
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}'`));