@@ -342,6 +342,12 @@ public void getFirewalledRequestWhenContainsUpperboundAsciiThenNoException() {
342342 this .firewall .getFirewalledRequest (this .request );
343343 }
344344
345+ @ Test
346+ public void getFirewalledRequestWhenJapaneseCharacterThenNoException () {
347+ this .request .setServletPath ("/\u3042 " );
348+ this .firewall .getFirewalledRequest (this .request );
349+ }
350+
345351 @ Test
346352 public void getFirewalledRequestWhenExceedsUpperboundAsciiThenException () {
347353 this .request .setRequestURI ("/\u007f " );
@@ -363,6 +369,20 @@ public void getFirewalledRequestWhenContainsEncodedNullThenException() {
363369 .isThrownBy (() -> this .firewall .getFirewalledRequest (this .request ));
364370 }
365371
372+ @ Test
373+ public void getFirewalledRequestWhenContainsLowercaseEncodedLineFeedThenException () {
374+ this .request .setRequestURI ("/something%0a/" );
375+ assertThatExceptionOfType (RequestRejectedException .class )
376+ .isThrownBy (() -> this .firewall .getFirewalledRequest (this .request ));
377+ }
378+
379+ @ Test
380+ public void getFirewalledRequestWhenContainsUppercaseEncodedLineFeedThenException () {
381+ this .request .setRequestURI ("/something%0A/" );
382+ assertThatExceptionOfType (RequestRejectedException .class )
383+ .isThrownBy (() -> this .firewall .getFirewalledRequest (this .request ));
384+ }
385+
366386 @ Test
367387 public void getFirewalledRequestWhenContainsLineFeedThenException () {
368388 this .request .setRequestURI ("/something\n /" );
@@ -377,6 +397,20 @@ public void getFirewalledRequestWhenServletPathContainsLineFeedThenException() {
377397 .isThrownBy (() -> this .firewall .getFirewalledRequest (this .request ));
378398 }
379399
400+ @ Test
401+ public void getFirewalledRequestWhenContainsLowercaseEncodedCarriageReturnThenException () {
402+ this .request .setRequestURI ("/something%0d/" );
403+ assertThatExceptionOfType (RequestRejectedException .class )
404+ .isThrownBy (() -> this .firewall .getFirewalledRequest (this .request ));
405+ }
406+
407+ @ Test
408+ public void getFirewalledRequestWhenContainsUppercaseEncodedCarriageReturnThenException () {
409+ this .request .setRequestURI ("/something%0D/" );
410+ assertThatExceptionOfType (RequestRejectedException .class )
411+ .isThrownBy (() -> this .firewall .getFirewalledRequest (this .request ));
412+ }
413+
380414 @ Test
381415 public void getFirewalledRequestWhenContainsCarriageReturnThenException () {
382416 this .request .setRequestURI ("/something\r /" );
@@ -391,6 +425,96 @@ public void getFirewalledRequestWhenServletPathContainsCarriageReturnThenExcepti
391425 .isThrownBy (() -> this .firewall .getFirewalledRequest (this .request ));
392426 }
393427
428+ @ Test
429+ public void getFirewalledRequestWhenServletPathContainsLineSeparatorThenException () {
430+ this .request .setServletPath ("/something\u2028 /" );
431+ assertThatExceptionOfType (RequestRejectedException .class )
432+ .isThrownBy (() -> this .firewall .getFirewalledRequest (this .request ));
433+ }
434+
435+ @ Test
436+ public void getFirewalledRequestWhenServletPathContainsParagraphSeparatorThenException () {
437+ this .request .setServletPath ("/something\u2029 /" );
438+ assertThatExceptionOfType (RequestRejectedException .class )
439+ .isThrownBy (() -> this .firewall .getFirewalledRequest (this .request ));
440+ }
441+
442+ @ Test
443+ public void getFirewalledRequestWhenContainsLowercaseEncodedLineFeedAndAllowedThenNoException () {
444+ this .firewall .setAllowUrlEncodedLineFeed (true );
445+ this .request .setRequestURI ("/something%0a/" );
446+ this .firewall .getFirewalledRequest (this .request );
447+ }
448+
449+ @ Test
450+ public void getFirewalledRequestWhenContainsUppercaseEncodedLineFeedAndAllowedThenNoException () {
451+ this .firewall .setAllowUrlEncodedLineFeed (true );
452+ this .request .setRequestURI ("/something%0A/" );
453+ this .firewall .getFirewalledRequest (this .request );
454+ }
455+
456+ @ Test
457+ public void getFirewalledRequestWhenContainsLineFeedAndAllowedThenException () {
458+ this .firewall .setAllowUrlEncodedLineFeed (true );
459+ this .request .setRequestURI ("/something\n /" );
460+ // Expected an error because the line feed is decoded in an encoded part of the
461+ // URL
462+ assertThatExceptionOfType (RequestRejectedException .class )
463+ .isThrownBy (() -> this .firewall .getFirewalledRequest (this .request ));
464+ }
465+
466+ @ Test
467+ public void getFirewalledRequestWhenServletPathContainsLineFeedAndAllowedThenNoException () {
468+ this .firewall .setAllowUrlEncodedLineFeed (true );
469+ this .request .setServletPath ("/something\n /" );
470+ this .firewall .getFirewalledRequest (this .request );
471+ }
472+
473+ @ Test
474+ public void getFirewalledRequestWhenContainsLowercaseEncodedCarriageReturnAndAllowedThenNoException () {
475+ this .firewall .setAllowUrlEncodedCarriageReturn (true );
476+ this .request .setRequestURI ("/something%0d/" );
477+ this .firewall .getFirewalledRequest (this .request );
478+ }
479+
480+ @ Test
481+ public void getFirewalledRequestWhenContainsUppercaseEncodedCarriageReturnAndAllowedThenNoException () {
482+ this .firewall .setAllowUrlEncodedCarriageReturn (true );
483+ this .request .setRequestURI ("/something%0D/" );
484+ this .firewall .getFirewalledRequest (this .request );
485+ }
486+
487+ @ Test
488+ public void getFirewalledRequestWhenContainsCarriageReturnAndAllowedThenNoException () {
489+ this .firewall .setAllowUrlEncodedCarriageReturn (true );
490+ this .request .setRequestURI ("/something\r /" );
491+ // Expected an error because the carriage return is decoded in an encoded part of
492+ // the URL
493+ assertThatExceptionOfType (RequestRejectedException .class )
494+ .isThrownBy (() -> this .firewall .getFirewalledRequest (this .request ));
495+ }
496+
497+ @ Test
498+ public void getFirewalledRequestWhenServletPathContainsCarriageReturnAndAllowedThenNoException () {
499+ this .firewall .setAllowUrlEncodedCarriageReturn (true );
500+ this .request .setServletPath ("/something\r /" );
501+ this .firewall .getFirewalledRequest (this .request );
502+ }
503+
504+ @ Test
505+ public void getFirewalledRequestWhenServletPathContainsLineSeparatorAndAllowedThenNoException () {
506+ this .firewall .setAllowUrlEncodedLineSeparator (true );
507+ this .request .setServletPath ("/something\u2028 /" );
508+ this .firewall .getFirewalledRequest (this .request );
509+ }
510+
511+ @ Test
512+ public void getFirewalledRequestWhenServletPathContainsParagraphSeparatorAndAllowedThenNoException () {
513+ this .firewall .setAllowUrlEncodedParagraphSeparator (true );
514+ this .request .setServletPath ("/something\u2029 /" );
515+ this .firewall .getFirewalledRequest (this .request );
516+ }
517+
394518 /**
395519 * On WebSphere 8.5 a URL like /context-root/a/b;%2f1/c can bypass a rule on /a/b/c
396520 * because the pathInfo is /a/b;/1/c which ends up being /a/b/1/c while Spring MVC
0 commit comments