From 34487947ba6e8bab3ae7f8942fc79915669a892a Mon Sep 17 00:00:00 2001 From: lifei6671 Date: Tue, 22 Jan 2019 18:51:39 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E4=BF=AE=E5=A4=8D=E9=93=BE=E6=8E=A5?= =?UTF-8?q?=E6=96=87=E7=AB=A0=E7=9A=84=E9=99=84=E4=BB=B6=E6=97=A0=E6=B3=95?= =?UTF-8?q?=E4=B8=8B=E8=BD=BD=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- controllers/BlogController.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/controllers/BlogController.go b/controllers/BlogController.go index 315eaa49..9735f3d6 100644 --- a/controllers/BlogController.go +++ b/controllers/BlogController.go @@ -632,16 +632,18 @@ func (c *BlogController) Download() { attachment, err := models.NewAttachment().Find(attachId) if err != nil { - beego.Error("DownloadAttachment => ", err) if err == orm.ErrNoRows { c.ShowErrorPage(404, "附件不存在") } else { + beego.Error("查询附件时出现异常 -> ", err) c.ShowErrorPage(500, "查询附件时出现异常") } } - if blog.BlogType == 1 && attachment.BookId != blog.BookId && attachment.DocumentId != blog.DocumentId { + + //如果是链接的文章,需要校验文档ID是否一致,如果不是,需要保证附件的项目ID为0且文档的ID等于博文ID + if blog.BlogType == 1 && attachment.DocumentId != blog.DocumentId { c.ShowErrorPage(404, "附件不存在") - } else if attachment.BookId != 0 || attachment.DocumentId != blogId { + } else if blog.BlogType != 1 && (attachment.BookId != 0 || attachment.DocumentId != blogId ) { c.ShowErrorPage(404, "附件不存在") }