Steve Piercy
2017-09-23 e0eda611a5e951acd56884fb48e7a3049821f836
use pyramid.compat.escape instead of cgi.escape
- backport of #3165 and #3171
1 files modified
6 ■■■■ changed files
docs/quick_tour/views/views.py 6 ●●●● patch | view | raw | blame | history
docs/quick_tour/views/views.py
@@ -1,4 +1,4 @@
import cgi
from pyramid.compat import escape
from pyramid.httpexceptions import HTTPFound
from pyramid.response import Response
@@ -16,8 +16,8 @@
def hello_view(request):
    name = request.params.get('name', 'No Name')
    body = '<p>Hi %s, this <a href="/goto">redirects</a></p>'
    # cgi.escape to prevent Cross-Site Scripting (XSS) [CWE 79]
    return Response(body % cgi.escape(name))
    # pyramid.compat.escape to prevent Cross-Site Scripting (XSS) [CWE 79]
    return Response(body % escape(name))
# /goto which issues HTTP redirect to the last view