Skip to content
Permalink
Browse files

adjusting the way the regex is done so its easier to read

  • Loading branch information...
dogmatic69 committed Sep 13, 2012
1 parent 25b4471 commit 50333a2866ccfcc5359fb4ca36ffa23729e38fa0
Showing with 7 additions and 2 deletions.
  1. +7 −2 lib/Cake/Utility/Sanitize.php
@@ -150,10 +150,15 @@ public static function stripImages($str) {
* 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);
}

0 comments on commit 50333a2

Please sign in to comment.
You can’t perform that action at this time.