-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix #2704: ensure route registered via $routes->cli() not accessible via web browser even autoroute is true #2707
Changes from 7 commits
5717767
73077d8
e90620f
fe5e0ca
200f981
e0807e3
04e0ad4
19fc140
e36edd7
92058e5
36a9a10
d5af6b3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?php namespace App\Controllers; | ||
|
||
use CodeIgniter\Controller; | ||
|
||
class Hello extends Controller | ||
{ | ||
public function index() | ||
{ | ||
return 'Hello'; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -204,4 +204,25 @@ public function testCallZeroAsPathGot404() | |
} | ||
$this->get('0'); | ||
} | ||
|
||
public function testOpenCliRoutesFromHttpGot404() | ||
{ | ||
$this->expectException(PageNotFoundException::class); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If I add the following test case, 'parameterized method cli' => [
'hello/(:segment)',
'Hello::$1',
'Hello/index',
], There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These tests pass because there is no |
||
|
||
require_once SUPPORTPATH . 'Controllers/Hello.php'; | ||
|
||
$this->withRoutes([ | ||
[ | ||
'cli', | ||
'hello', | ||
'Hello::index', | ||
], | ||
]); | ||
|
||
while (\ob_get_level() > 0) | ||
{ | ||
\ob_end_flush(); | ||
} | ||
$this->get('Hello'); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
using
strpos
is on purpose to handle parameter, eg: controller::method/$1: