basic XSS protection m)
This commit is contained in:
parent
443eb2bbe1
commit
a15338209b
@ -3,6 +3,8 @@
|
|||||||
# Copyright 2012, Martin Zimmermann <info@posativ.org>. All rights reserved.
|
# Copyright 2012, Martin Zimmermann <info@posativ.org>. All rights reserved.
|
||||||
# License: BSD Style, 2 clauses. see isso/__init__.py
|
# License: BSD Style, 2 clauses. see isso/__init__.py
|
||||||
|
|
||||||
|
import cgi
|
||||||
|
|
||||||
from werkzeug.wrappers import Response
|
from werkzeug.wrappers import Response
|
||||||
from werkzeug.exceptions import abort
|
from werkzeug.exceptions import abort
|
||||||
|
|
||||||
@ -17,7 +19,19 @@ def create(app, environ, request, path):
|
|||||||
return abort(404)
|
return abort(404)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
rv = app.db.add(path, models.Comment.fromjson(request.data))
|
comment = models.Comment.fromjson(request.data)
|
||||||
|
except ValueError:
|
||||||
|
return abort(400)
|
||||||
|
|
||||||
|
for attr in 'author', 'email', 'website':
|
||||||
|
if getattr(comment, attr) is not None:
|
||||||
|
try:
|
||||||
|
setattr(comment, attr, cgi.escape(getattr(comment, attr)))
|
||||||
|
except AttributeError:
|
||||||
|
abort(400)
|
||||||
|
|
||||||
|
try:
|
||||||
|
rv = app.db.add(path, comment)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
return abort(400)
|
return abort(400)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user