summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorTres Seaver <tseaver@palladion.com>2014-04-15 14:28:52 -0400
committerTres Seaver <tseaver@palladion.com>2014-04-15 14:28:52 -0400
commit492cfd6b7a94ade1bc89855f3a15cbcc5bfa7f57 (patch)
treec864c7d12cceb8ba264ff11c30ef00251df747aa /docs
parent133e75fe04e587a6d11e3a501b5e34793ef440bc (diff)
parent4083b3bb431b464f330fb17e22a6465aeb6f2fe0 (diff)
downloadpyramid-492cfd6b7a94ade1bc89855f3a15cbcc5bfa7f57.tar.gz
pyramid-492cfd6b7a94ade1bc89855f3a15cbcc5bfa7f57.tar.bz2
pyramid-492cfd6b7a94ade1bc89855f3a15cbcc5bfa7f57.zip
Merge pull request #1296 from westurner/1294_add_cgi_escape_to_quick_tour
DOC: Add cgi.escape to quick_tour/views/views.py (Fixes #1294)
Diffstat (limited to 'docs')
-rw-r--r--docs/quick_tour/views/views.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/docs/quick_tour/views/views.py b/docs/quick_tour/views/views.py
index 9dc795f14..1449cbb38 100644
--- a/docs/quick_tour/views/views.py
+++ b/docs/quick_tour/views/views.py
@@ -1,3 +1,5 @@
+import cgi
+
from pyramid.httpexceptions import HTTPFound
from pyramid.response import Response
from pyramid.view import view_config
@@ -14,7 +16,8 @@ def home_view(request):
def hello_view(request):
name = request.params.get('name', 'No Name')
body = '<p>Hi %s, this <a href="/goto">redirects</a></p>'
- return Response(body % name)
+ # cgi.escape to prevent Cross-Site Scripting (XSS) [CWE 79]
+ return Response(body % cgi.escape(name))
# /goto which issues HTTP redirect to the last view
@@ -23,7 +26,7 @@ def redirect_view(request):
return HTTPFound(location="/problem")
-# /problem which causes an site error
+# /problem which causes a site error
@view_config(route_name='exception')
def exception_view(request):
raise Exception()