1313
1414use CodeIgniter \Config \Services ;
1515use CodeIgniter \Exceptions \PageNotFoundException ;
16+ use CodeIgniter \HTTP \Exceptions \BadRequestException ;
1617use CodeIgniter \HTTP \Exceptions \RedirectException ;
1718use CodeIgniter \HTTP \IncomingRequest ;
1819use CodeIgniter \Router \Exceptions \RouterException ;
1920use CodeIgniter \Test \CIUnitTestCase ;
21+ use Config \App ;
2022use Config \Modules ;
2123use Config \Routing ;
2224use Tests \Support \Filters \Customfilter ;
@@ -87,6 +89,16 @@ public function testZeroAsURIPath(): void
8789 $ router ->handle ('0 ' );
8890 }
8991
92+ public function testNotPermittedChars (): void
93+ {
94+ $ router = new Router ($ this ->collection , $ this ->request );
95+
96+ $ this ->expectException (BadRequestException::class);
97+ $ this ->expectExceptionMessage ('The URI you submitted has disallowed characters: "<a>" ' );
98+
99+ $ router ->handle ('test/%3Ca%3E ' );
100+ }
101+
90102 public function testURIMapsToController (): void
91103 {
92104 $ router = new Router ($ this ->collection , $ this ->request );
@@ -783,6 +795,9 @@ public function testAutoRouteMethodEmpty(): void
783795 */
784796 public function testRegularExpressionWithUnicode (): void
785797 {
798+ $ config = config (App::class);
799+ $ config ->permittedURIChars = 'a-z 0-9~%.:_\-\x{0980}-\x{09ff} ' ;
800+
786801 $ this ->collection ->get ('news/([a-z0-9\x{0980}-\x{09ff}-]+) ' , 'News::view/$1 ' );
787802
788803 $ router = new Router ($ this ->collection , $ this ->request );
@@ -802,6 +817,9 @@ public function testRegularExpressionWithUnicode(): void
802817 */
803818 public function testRegularExpressionPlaceholderWithUnicode (): void
804819 {
820+ $ config = config (App::class);
821+ $ config ->permittedURIChars = 'a-z 0-9~%.:_\-\x{0980}-\x{09ff} ' ;
822+
805823 $ this ->collection ->addPlaceholder ('custom ' , '[a-z0-9\x{0980}-\x{09ff}-]+ ' );
806824 $ this ->collection ->get ('news/(:custom) ' , 'News::view/$1 ' );
807825
0 commit comments