Skip to content

Commit a3e8039

Browse files
committed
Fix esc() for 'raw' context (#8624)
1 parent b8adef6 commit a3e8039

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

system/Common.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,13 @@ function env(string $key, $default = null)
426426
*/
427427
function esc($data, string $context = 'html', ?string $encoding = null)
428428
{
429+
// Provide a way to NOT escape data since
430+
// this could be called automatically by
431+
// the View library.
432+
if ($context === 'raw') {
433+
return $data;
434+
}
435+
429436
if (is_array($data)) {
430437
foreach ($data as &$value) {
431438
$value = esc($value, $context);
@@ -435,13 +442,6 @@ function esc($data, string $context = 'html', ?string $encoding = null)
435442
if (is_string($data)) {
436443
$context = strtolower($context);
437444

438-
// Provide a way to NOT escape data since
439-
// this could be called automatically by
440-
// the View library.
441-
if ($context === 'raw') {
442-
return $data;
443-
}
444-
445445
if (! in_array($context, ['html', 'js', 'css', 'url', 'attr'], true)) {
446446
throw new InvalidArgumentException('Invalid escape context provided.');
447447
}

0 commit comments

Comments
 (0)