fix: bug that esc() accepts invalid context '0'

This commit is contained in:
kenjis 2022-10-20 10:50:51 +09:00
parent 7a631a134b
commit 811c4a7306
No known key found for this signature in database
GPG Key ID: BD254878922AF198
2 changed files with 7 additions and 1 deletions

View File

@ -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;
}

View File

@ -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
*