mirror of
https://github.com/codeigniter4/CodeIgniter4.git
synced 2025-02-20 11:44:28 +08:00
fix: bug that esc() accepts invalid context '0'
This commit is contained in:
parent
7a631a134b
commit
811c4a7306
@ -437,7 +437,7 @@ if (! function_exists('esc')) {
|
||||
// Provide a way to NOT escape data since
|
||||
// this could be called automatically by
|
||||
// the View library.
|
||||
if (empty($context) || $context === 'raw') {
|
||||
if ($context === 'raw') {
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
@ -177,6 +177,12 @@ final class CommonFunctionsTest extends CIUnitTestCase
|
||||
esc(['width' => '800', 'height' => '600'], 'bogus');
|
||||
}
|
||||
|
||||
public function testEscapeBadContextZero()
|
||||
{
|
||||
$this->expectException('InvalidArgumentException');
|
||||
esc('<script>', '0');
|
||||
}
|
||||
|
||||
/**
|
||||
* @runInSeparateProcess
|
||||
*
|
||||
|
Loading…
x
Reference in New Issue
Block a user