@@ -176,108 +176,6 @@ describe('extractRoutesAndCreateRouteTree', () => {
176176 ) ;
177177 } ) ;
178178
179- it ( "should error when a server route 'headers.Location' uses an unsupported protocol" , async ( ) => {
180- setAngularAppTestingManifest (
181- [ { path : 'external' , component : DummyComponent } ] ,
182- [
183- {
184- path : 'external' ,
185- renderMode : RenderMode . Prerender ,
186- headers : { Location : 'javascript:alert(1)' } ,
187- } ,
188- { path : '**' , renderMode : RenderMode . Server } ,
189- ] ,
190- ) ;
191-
192- const { errors } = await extractRoutesAndCreateRouteTree ( { url } ) ;
193- expect ( errors [ 0 ] ) . toContain (
194- `Invalid 'external' route configuration: the 'headers.Location' value is invalid: ` +
195- `the 'javascript:' protocol is not supported as a redirect target.` ,
196- ) ;
197- } ) ;
198-
199- it ( "should error when a server route 'headers.Location' contains a backslash" , async ( ) => {
200- setAngularAppTestingManifest (
201- [ { path : 'external' , component : DummyComponent } ] ,
202- [
203- {
204- path : 'external' ,
205- renderMode : RenderMode . Prerender ,
206- headers : { Location : '/\\evil.example' } ,
207- } ,
208- { path : '**' , renderMode : RenderMode . Server } ,
209- ] ,
210- ) ;
211-
212- const { errors } = await extractRoutesAndCreateRouteTree ( { url } ) ;
213- expect ( errors [ 0 ] ) . toContain (
214- `Invalid 'external' route configuration: the 'headers.Location' value is invalid: ` +
215- `'/\\evil.example' is not a valid same-origin path.` ,
216- ) ;
217- } ) ;
218-
219- it ( "should error when a server route 'headers.Location' resolves into a protocol-relative path" , async ( ) => {
220- setAngularAppTestingManifest (
221- [ { path : 'external' , component : DummyComponent } ] ,
222- [
223- {
224- path : 'external' ,
225- renderMode : RenderMode . Server ,
226- status : 302 ,
227- headers : { Location : '/..//evil.example' } ,
228- } ,
229- { path : '**' , renderMode : RenderMode . Server } ,
230- ] ,
231- ) ;
232-
233- const { errors } = await extractRoutesAndCreateRouteTree ( { url } ) ;
234- expect ( errors [ 0 ] ) . toContain (
235- `Invalid 'external' route configuration: the 'headers.Location' value is invalid: ` +
236- `'/..//evil.example' is not a valid same-origin path. ` +
237- `It resolves to the protocol-relative path '//evil.example'.` ,
238- ) ;
239- } ) ;
240-
241- it ( "should error when a server route 'headers.Location' uses an unsupported protocol regardless of the header casing" , async ( ) => {
242- setAngularAppTestingManifest (
243- [ { path : 'external' , component : DummyComponent } ] ,
244- [
245- {
246- path : 'external' ,
247- renderMode : RenderMode . Prerender ,
248- headers : { LoCaTiOn : 'javascript:alert(1)' } ,
249- } ,
250- { path : '**' , renderMode : RenderMode . Server } ,
251- ] ,
252- ) ;
253-
254- const { errors } = await extractRoutesAndCreateRouteTree ( { url } ) ;
255- expect ( errors [ 0 ] ) . toContain (
256- `Invalid 'external' route configuration: the 'headers.Location' value is invalid: ` +
257- `the 'javascript:' protocol is not supported as a redirect target.` ,
258- ) ;
259- } ) ;
260-
261- it ( "should store the normalized value of a server route 'headers.Location'" , async ( ) => {
262- setAngularAppTestingManifest (
263- [ { path : 'external' , component : DummyComponent } ] ,
264- [
265- {
266- path : 'external' ,
267- renderMode : RenderMode . Server ,
268- headers : { location : 'HTTPS://Example.com/A b' } ,
269- } ,
270- { path : '**' , renderMode : RenderMode . Server } ,
271- ] ,
272- ) ;
273-
274- const { routeTree, errors } = await extractRoutesAndCreateRouteTree ( { url } ) ;
275- expect ( errors ) . toHaveSize ( 0 ) ;
276- expect ( routeTree . match ( '/external' ) ?. headers ) . toEqual ( {
277- location : 'https://example.com/A%20b' ,
278- } ) ;
279- } ) ;
280-
281179 it ( "should error when 'getPrerenderParams' produces a segment which decodes to a separator" , async ( ) => {
282180 setAngularAppTestingManifest (
283181 [ { path : 'store/:slug' , component : DummyComponent } ] ,
0 commit comments