Skip to content
This repository has been archived by the owner on May 8, 2018. It is now read-only.

Commit

Permalink
fliter post title html tags
Browse files Browse the repository at this point in the history
  • Loading branch information
Rabbit_52 committed Dec 6, 2012
1 parent 0aefc8d commit 25cc34c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion controllers/post.py
Expand Up @@ -100,7 +100,7 @@ def POST(self, node_name):
if session.money < cost:
self.crumb.append('财富不够')
return render.no_money('财富不够', '你的财富值不够,不能创建改主题 :(', self.crumb.output())
title = html2db(self.form.d.title)
title = strip_tags(self.form.d.title)
content = html2db(self.form.d.content)
content, receiver_list = notify_model().convert_content(content)
create_time = time.time()
Expand Down
13 changes: 12 additions & 1 deletion libraries/helper.py
Expand Up @@ -135,4 +135,15 @@ def list_diff(list_1, list_2):
for item in list_1:
if item not in list_2:
list_.append(item)
return list_
return list_

def strip_tags(html):
from HTMLParser import HTMLParser
html=html.strip()
html=html.strip("\n")
result=[]
parse=HTMLParser()
parse.handle_data=result.append
parse.feed(html)
parse.close()
return "".join(result)

0 comments on commit 25cc34c

Please sign in to comment.