Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
rhukster committed May 6, 2024
1 parent 77adfcb commit b6bba9e
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion system/src/Grav/Common/Security.php
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ public static function detectXss($string, array $options = null): ?string
// Set the patterns we'll test against
$patterns = [
// Match any attribute starting with "on" or xmlns
'on_events' => '#(<[^>]+[[a-z\x00-\x20\"\'\/])([\s\/]on|\sxmlns)[a-z].*=>?#iUu',
'on_events' => '#(<[^>]+[a-z\x00-\x20\"\'\/])(on[a-z]+|xmlns)\s*=[\s|\'\"].*[\s|\'\"]>#iUu',

// Match javascript:, livescript:, vbscript:, mocha:, feed: and data: protocols
'invalid_protocols' => '#(' . implode('|', array_map('preg_quote', $invalid_protocols, ['#'])) . ')(:|\&\#58)\S.*?#iUu',
Expand Down Expand Up @@ -279,6 +279,7 @@ public static function cleanDangerousTwig(string $string): string
'twig.getFunction',
'core.setEscaper',
'twig.safe_functions',
'read_file',
];
$string = preg_replace('/(({{\s*|{%\s*)[^}]*?(' . implode('|', $bad_twig) . ')[^}]*?(\s*}}|\s*%}))/i', '{# $1 #}', $string);
return $string;
Expand Down

0 comments on commit b6bba9e

Please sign in to comment.