File tree Expand file tree Collapse file tree 2 files changed +14
-0
lines changed Expand file tree Collapse file tree 2 files changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -176,6 +176,7 @@ def requires_calendar():
176
176
from flask import request
177
177
from flask import session
178
178
from flask import url_for
179
+ import markupsafe
179
180
except ImportError : # pragma: NO COVER
180
181
raise ImportError ('The flask utilities require flask 0.9 or newer.' )
181
182
@@ -388,6 +389,7 @@ def callback_view(self):
388
389
if 'error' in request .args :
389
390
reason = request .args .get (
390
391
'error_description' , request .args .get ('error' , '' ))
392
+ reason = markupsafe .escape (reason )
391
393
return ('Authorization failed: {0}' .format (reason ),
392
394
httplib .BAD_REQUEST )
393
395
Original file line number Diff line number Diff line change @@ -258,6 +258,18 @@ def test_callback_view_errors(self):
258
258
self .assertEqual (response .status_code , httplib .BAD_REQUEST )
259
259
self .assertIn ('something' , response .data .decode ('utf-8' ))
260
260
261
+ # Error supplied to callback with html
262
+ with self .app .test_client () as client :
263
+ with client .session_transaction () as session :
264
+ session ['google_oauth2_csrf_token' ] = 'tokenz'
265
+
266
+ response = client .get (
267
+ '/oauth2callback?state={}&error=<script>something<script>' )
268
+ self .assertEqual (response .status_code , httplib .BAD_REQUEST )
269
+ self .assertIn (
270
+ '<script>something<script>' ,
271
+ response .data .decode ('utf-8' ))
272
+
261
273
# CSRF mismatch
262
274
with self .app .test_client () as client :
263
275
with client .session_transaction () as session :
You can’t perform that action at this time.
0 commit comments