Skip to content

Commit 88ec458

Browse files
committed
esc() for 'raw' context (Fixes #8624)
1 parent b8adef6 commit 88ec458

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

system/Common.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -426,22 +426,22 @@ function env(string $key, $default = null)
426426
*/
427427
function esc($data, string $context = 'html', ?string $encoding = null)
428428
{
429+
$context = strtolower($context);
430+
431+
// Provide a way to NOT escape data since
432+
// this could be called automatically by
433+
// the View library.
434+
if ($context === 'raw') {
435+
return $data;
436+
}
437+
429438
if (is_array($data)) {
430439
foreach ($data as &$value) {
431440
$value = esc($value, $context);
432441
}
433442
}
434443

435444
if (is_string($data)) {
436-
$context = strtolower($context);
437-
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)