增加富文本的 xss 过滤

This commit is contained in:
virusdefender
2015-09-22 17:03:53 +08:00
parent b224a823fe
commit c26fd6734d
8 changed files with 288 additions and 3 deletions

14
utils/models.py Normal file
View File

@@ -0,0 +1,14 @@
# coding=utf-8
from django.db import models
from utils.xss_filter import XssHtml
class RichTextField(models.TextField):
__metaclass__ = models.SubfieldBase
def get_prep_value(self, value):
parser = XssHtml()
parser.feed(value)
parser.close()
return parser.getHtml()