@@ -440,6 +440,82 @@ public void getFirewalledRequestWhenServletPathContainsParagraphSeparatorThenExc
440440 .isThrownBy (() -> this .firewall .getFirewalledRequest (this .request ));
441441 }
442442
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+
443519 /**
444520 * On WebSphere 8.5 a URL like /context-root/a/b;%2f1/c can bypass a rule on /a/b/c
445521 * because the pathInfo is /a/b;/1/c which ends up being /a/b/1/c while Spring MVC
0 commit comments