File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1212namespace CodeIgniter \HTTP ;
1313
1414use BadMethodCallException ;
15+ use CodeIgniter \Exceptions \ConfigException ;
1516use CodeIgniter \HTTP \Exceptions \HTTPException ;
1617use Config \App ;
1718
@@ -75,6 +76,13 @@ public function __construct(App $configApp)
7576 // baseURL, so let's help them out.
7677 $ baseURL = rtrim ($ configApp ->baseURL , '/ ' ) . '/ ' ;
7778
79+ // Validate baseURL
80+ if (filter_var ($ baseURL , FILTER_VALIDATE_URL ) === false ) {
81+ throw new ConfigException (
82+ 'Config\App::$baseURL is invalid. '
83+ );
84+ }
85+
7886 $ this ->baseURL = $ baseURL ;
7987 $ this ->indexPage = $ configApp ->indexPage ;
8088
Original file line number Diff line number Diff line change 1212namespace CodeIgniter \HTTP ;
1313
1414use BadMethodCallException ;
15+ use CodeIgniter \Exceptions \ConfigException ;
1516use CodeIgniter \HTTP \Exceptions \HTTPException ;
1617use CodeIgniter \Test \CIUnitTestCase ;
1718use Config \App ;
@@ -68,6 +69,16 @@ public function testConstructorIndexPageEmpty()
6869 $ this ->assertSame ('http://example.com/ ' , (string ) $ uri );
6970 }
7071
72+ public function testConstructorInvalidBaseURL ()
73+ {
74+ $ this ->expectException (ConfigException::class);
75+
76+ $ config = new App ();
77+ $ config ->baseURL = 'invalid ' ;
78+
79+ new SiteURI ($ config );
80+ }
81+
7182 public function testSetPath ()
7283 {
7384 $ config = new App ();
You can’t perform that action at this time.
0 commit comments