File tree Expand file tree Collapse file tree 2 files changed +11
-0
lines changed
oauth2client/contrib/django_util
tests/contrib/django_util Expand file tree Collapse file tree 2 files changed +11
-0
lines changed Original file line number Diff line number Diff line change 28
28
from django .conf import settings
29
29
from django .core import urlresolvers
30
30
from django .shortcuts import redirect
31
+ from django .utils import html
31
32
import jsonpickle
32
33
from six .moves .urllib import parse
33
34
@@ -109,6 +110,7 @@ def oauth2_callback(request):
109
110
if 'error' in request .GET :
110
111
reason = request .GET .get (
111
112
'error_description' , request .GET .get ('error' , '' ))
113
+ reason = html .escape (reason )
112
114
return http .HttpResponseBadRequest (
113
115
'Authorization failed {0}' .format (reason ))
114
116
Original file line number Diff line number Diff line change @@ -249,6 +249,15 @@ def test_error_returns_bad_request(self):
249
249
self .assertIsInstance (response , http .HttpResponseBadRequest )
250
250
self .assertIn (b'Authorization failed' , response .content )
251
251
252
+ def test_error_escapes_html (self ):
253
+ request = self .factory .get ('oauth2/oauth2callback' , data = {
254
+ 'error' : '<script>bad</script>' ,
255
+ })
256
+ response = views .oauth2_callback (request )
257
+ self .assertIsInstance (response , http .HttpResponseBadRequest )
258
+ self .assertNotIn (b'<script>' , response .content )
259
+ self .assertIn (b'<script>' , response .content )
260
+
252
261
def test_no_session (self ):
253
262
request = self .factory .get ('oauth2/oauth2callback' , data = {
254
263
'code' : 123 ,
You can’t perform that action at this time.
0 commit comments