@@ -131,6 +131,26 @@ func TestServer(t *testing.T) {
131131 testTemplate : true ,
132132 testErrDescriptionXSS : true ,
133133 },
134+ {
135+ desc : "Error: Query Values missing 'state' key, using optional fail error page - Error Code XSS test" ,
136+ reqState : "state" ,
137+ port : 0 ,
138+ q : url.Values {"error" : []string {"<script>alert('this code snippet was executed')</script>" }, "error_description" : []string {"error_description" }},
139+ statusCode : 200 ,
140+ errorPage : []byte ("error: {{.Code}} error_description: {{.Err}}" ),
141+ testTemplate : true ,
142+ testErrCodeXSS : true ,
143+ },
144+ {
145+ desc : "Error: Query Values missing 'state' key, using optional fail error page - Error Description XSS test" ,
146+ reqState : "state" ,
147+ port : 0 ,
148+ q : url.Values {"error" : []string {"error_code" }, "error_description" : []string {"<script>alert('this code snippet was executed')</script>" }},
149+ statusCode : 200 ,
150+ errorPage : []byte ("error: {{.Code}} error_description: {{.Err}}" ),
151+ testTemplate : true ,
152+ testErrDescriptionXSS : true ,
153+ },
134154 }
135155
136156 for _ , test := range tests {
@@ -212,6 +232,13 @@ func TestServer(t *testing.T) {
212232 continue
213233 }
214234
235+ if len (test .errorPage ) > 0 && (test .testErrCodeXSS || test .testErrDescriptionXSS ) {
236+ if ! strings .Contains (string (content ), "<script>alert('this code snippet was executed')</script>" ) {
237+ t .Errorf ("TestServer(%s): want escaped html entities" , test .desc )
238+ }
239+ continue
240+ }
241+
215242 if len (test .errorPage ) > 0 {
216243 errCode := bytes .Contains (test .errorPage , []byte ("{{.Code}}" ))
217244 errDescription := bytes .Contains (test .errorPage , []byte ("{{.Err}}" ))
0 commit comments