mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Merge pull request #831 from dogmatic69/sanitize-regex-cleanup
adjusting the way the regex is done so its easier to read
This commit is contained in:
commit
31ca237709
1 changed files with 7 additions and 2 deletions
|
@ -150,10 +150,15 @@ class Sanitize {
|
|||
* Strips scripts and stylesheets from output
|
||||
*
|
||||
* @param string $str String to sanitize
|
||||
* @return string String with <script>, <style>, <link>, <img> elements removed.
|
||||
* @return string String with <link>, <img>, <script>, <style> elements and html comments removed.
|
||||
*/
|
||||
public static function stripScripts($str) {
|
||||
$regex = '/(<link[^>]+rel="[^"]*stylesheet"[^>]*>|<img[^>]*>|style="[^"]*")|<script[^>]*>.*?<\/script>|<style[^>]*>.*?<\/style>|<!--.*?-->/is';
|
||||
$regex =
|
||||
'/(<link[^>]+rel="[^"]*stylesheet"[^>]*>|' .
|
||||
'<img[^>]*>|style="[^"]*")|' .
|
||||
'<script[^>]*>.*?<\/script>|' .
|
||||
'<style[^>]*>.*?<\/style>|' .
|
||||
'<!--.*?-->/is';
|
||||
return preg_replace($regex, '', $str);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue