Skip to content

Commit

Permalink
Fix XSS vulnerability by escaping comments
Browse files Browse the repository at this point in the history
  • Loading branch information
naoyak committed Jun 3, 2020
1 parent d1874d3 commit f026ad2
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions knowledge_repo/app/routes/comment.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
- /delete_comment
"""
import logging
from flask import request, Blueprint, g
from flask import request, Blueprint, g, escape

from .. import permissions
from ..proxies import db_session, current_user
Expand Down Expand Up @@ -43,8 +43,7 @@ def post_comment():
.first())
else:
comment = Comment(post_id=post.id)

comment.text = data['text']
comment.text = escape(data['text'])
comment.user_id = current_user.id
db_session.add(comment)
db_session.commit()
Expand Down

0 comments on commit f026ad2

Please sign in to comment.