@@ -343,6 +343,12 @@ public void getFirewalledRequestWhenContainsUpperboundAsciiThenNoException() {
343
343
this .firewall .getFirewalledRequest (this .request );
344
344
}
345
345
346
+ @ Test
347
+ public void getFirewalledRequestWhenJapaneseCharacterThenNoException () {
348
+ this .request .setServletPath ("/\u3042 " );
349
+ this .firewall .getFirewalledRequest (this .request );
350
+ }
351
+
346
352
@ Test
347
353
public void getFirewalledRequestWhenExceedsUpperboundAsciiThenException () {
348
354
this .request .setRequestURI ("/\u007f " );
@@ -364,6 +370,20 @@ public void getFirewalledRequestWhenContainsEncodedNullThenException() {
364
370
.isThrownBy (() -> this .firewall .getFirewalledRequest (this .request ));
365
371
}
366
372
373
+ @ Test
374
+ public void getFirewalledRequestWhenContainsLowercaseEncodedLineFeedThenException () {
375
+ this .request .setRequestURI ("/something%0a/" );
376
+ assertThatExceptionOfType (RequestRejectedException .class )
377
+ .isThrownBy (() -> this .firewall .getFirewalledRequest (this .request ));
378
+ }
379
+
380
+ @ Test
381
+ public void getFirewalledRequestWhenContainsUppercaseEncodedLineFeedThenException () {
382
+ this .request .setRequestURI ("/something%0A/" );
383
+ assertThatExceptionOfType (RequestRejectedException .class )
384
+ .isThrownBy (() -> this .firewall .getFirewalledRequest (this .request ));
385
+ }
386
+
367
387
@ Test
368
388
public void getFirewalledRequestWhenContainsLineFeedThenException () {
369
389
this .request .setRequestURI ("/something\n /" );
@@ -378,6 +398,20 @@ public void getFirewalledRequestWhenServletPathContainsLineFeedThenException() {
378
398
.isThrownBy (() -> this .firewall .getFirewalledRequest (this .request ));
379
399
}
380
400
401
+ @ Test
402
+ public void getFirewalledRequestWhenContainsLowercaseEncodedCarriageReturnThenException () {
403
+ this .request .setRequestURI ("/something%0d/" );
404
+ assertThatExceptionOfType (RequestRejectedException .class )
405
+ .isThrownBy (() -> this .firewall .getFirewalledRequest (this .request ));
406
+ }
407
+
408
+ @ Test
409
+ public void getFirewalledRequestWhenContainsUppercaseEncodedCarriageReturnThenException () {
410
+ this .request .setRequestURI ("/something%0D/" );
411
+ assertThatExceptionOfType (RequestRejectedException .class )
412
+ .isThrownBy (() -> this .firewall .getFirewalledRequest (this .request ));
413
+ }
414
+
381
415
@ Test
382
416
public void getFirewalledRequestWhenContainsCarriageReturnThenException () {
383
417
this .request .setRequestURI ("/something\r /" );
@@ -392,6 +426,96 @@ public void getFirewalledRequestWhenServletPathContainsCarriageReturnThenExcepti
392
426
.isThrownBy (() -> this .firewall .getFirewalledRequest (this .request ));
393
427
}
394
428
429
+ @ Test
430
+ public void getFirewalledRequestWhenServletPathContainsLineSeparatorThenException () {
431
+ this .request .setServletPath ("/something\u2028 /" );
432
+ assertThatExceptionOfType (RequestRejectedException .class )
433
+ .isThrownBy (() -> this .firewall .getFirewalledRequest (this .request ));
434
+ }
435
+
436
+ @ Test
437
+ public void getFirewalledRequestWhenServletPathContainsParagraphSeparatorThenException () {
438
+ this .request .setServletPath ("/something\u2029 /" );
439
+ assertThatExceptionOfType (RequestRejectedException .class )
440
+ .isThrownBy (() -> this .firewall .getFirewalledRequest (this .request ));
441
+ }
442
+
443
+ @ Test
444
+ public void getFirewalledRequestWhenContainsLowercaseEncodedLineFeedAndAllowedThenNoException () {
445
+ this .firewall .setAllowUrlEncodedLineFeed (true );
446
+ this .request .setRequestURI ("/something%0a/" );
447
+ this .firewall .getFirewalledRequest (this .request );
448
+ }
449
+
450
+ @ Test
451
+ public void getFirewalledRequestWhenContainsUppercaseEncodedLineFeedAndAllowedThenNoException () {
452
+ this .firewall .setAllowUrlEncodedLineFeed (true );
453
+ this .request .setRequestURI ("/something%0A/" );
454
+ this .firewall .getFirewalledRequest (this .request );
455
+ }
456
+
457
+ @ Test
458
+ public void getFirewalledRequestWhenContainsLineFeedAndAllowedThenException () {
459
+ this .firewall .setAllowUrlEncodedLineFeed (true );
460
+ this .request .setRequestURI ("/something\n /" );
461
+ // Expected an error because the line feed is decoded in an encoded part of the
462
+ // URL
463
+ assertThatExceptionOfType (RequestRejectedException .class )
464
+ .isThrownBy (() -> this .firewall .getFirewalledRequest (this .request ));
465
+ }
466
+
467
+ @ Test
468
+ public void getFirewalledRequestWhenServletPathContainsLineFeedAndAllowedThenNoException () {
469
+ this .firewall .setAllowUrlEncodedLineFeed (true );
470
+ this .request .setServletPath ("/something\n /" );
471
+ this .firewall .getFirewalledRequest (this .request );
472
+ }
473
+
474
+ @ Test
475
+ public void getFirewalledRequestWhenContainsLowercaseEncodedCarriageReturnAndAllowedThenNoException () {
476
+ this .firewall .setAllowUrlEncodedCarriageReturn (true );
477
+ this .request .setRequestURI ("/something%0d/" );
478
+ this .firewall .getFirewalledRequest (this .request );
479
+ }
480
+
481
+ @ Test
482
+ public void getFirewalledRequestWhenContainsUppercaseEncodedCarriageReturnAndAllowedThenNoException () {
483
+ this .firewall .setAllowUrlEncodedCarriageReturn (true );
484
+ this .request .setRequestURI ("/something%0D/" );
485
+ this .firewall .getFirewalledRequest (this .request );
486
+ }
487
+
488
+ @ Test
489
+ public void getFirewalledRequestWhenContainsCarriageReturnAndAllowedThenNoException () {
490
+ this .firewall .setAllowUrlEncodedCarriageReturn (true );
491
+ this .request .setRequestURI ("/something\r /" );
492
+ // Expected an error because the carriage return is decoded in an encoded part of
493
+ // the URL
494
+ assertThatExceptionOfType (RequestRejectedException .class )
495
+ .isThrownBy (() -> this .firewall .getFirewalledRequest (this .request ));
496
+ }
497
+
498
+ @ Test
499
+ public void getFirewalledRequestWhenServletPathContainsCarriageReturnAndAllowedThenNoException () {
500
+ this .firewall .setAllowUrlEncodedCarriageReturn (true );
501
+ this .request .setServletPath ("/something\r /" );
502
+ this .firewall .getFirewalledRequest (this .request );
503
+ }
504
+
505
+ @ Test
506
+ public void getFirewalledRequestWhenServletPathContainsLineSeparatorAndAllowedThenNoException () {
507
+ this .firewall .setAllowUrlEncodedLineSeparator (true );
508
+ this .request .setServletPath ("/something\u2028 /" );
509
+ this .firewall .getFirewalledRequest (this .request );
510
+ }
511
+
512
+ @ Test
513
+ public void getFirewalledRequestWhenServletPathContainsParagraphSeparatorAndAllowedThenNoException () {
514
+ this .firewall .setAllowUrlEncodedParagraphSeparator (true );
515
+ this .request .setServletPath ("/something\u2029 /" );
516
+ this .firewall .getFirewalledRequest (this .request );
517
+ }
518
+
395
519
/**
396
520
* On WebSphere 8.5 a URL like /context-root/a/b;%2f1/c can bypass a rule on /a/b/c
397
521
* because the pathInfo is /a/b;/1/c which ends up being /a/b/1/c while Spring MVC
0 commit comments