Skip to content

Commit f4d7f9e

Browse files
committed
修复部分代码漏洞
1 parent ef8174d commit f4d7f9e

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

accounts/views.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,8 @@ def account_result(request):
153153
if type and type in ['register', 'validation']:
154154
if type == 'register':
155155
content = '''
156-
恭喜您注册成功,一封验证邮件已经发送到您 {email} 的邮箱,请验证您的邮箱后登录本站。
157-
'''.format(email=user.email)
156+
恭喜您注册成功,一封验证邮件已经发送到您的邮箱,请验证您的邮箱后登录本站。
157+
'''
158158
title = '注册成功'
159159
else:
160160
c_sign = get_sha256(get_sha256(settings.SECRET_KEY + str(user.id)))

comments/urls.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
app_name = "comments"
66
urlpatterns = [
7-
# url(r'^po456stcomment/(?P<article_id>\d+)$', views.CommentPostView.as_view(), name='postcomment'),
87
path(
98
'article/<int:article_id>/postcomment',
109
views.CommentPostView.as_view(),

comments/views.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# Create your views here.
2+
from django.core.exceptions import ValidationError
23
from django.http import HttpResponseRedirect
34
from django.utils.decorators import method_decorator
45
from django.views.decorators.csrf import csrf_protect
@@ -40,6 +41,8 @@ def form_valid(self, form):
4041
article_id = self.kwargs['article_id']
4142
article = Article.objects.get(pk=article_id)
4243

44+
if article.comment_status == 'c' or article.status == 'c':
45+
raise ValidationError("该文章评论已关闭.")
4346
comment = form.save(False)
4447
comment.article = article
4548

0 commit comments

Comments
 (0)