Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

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

  • Loading branch information...
commit 50333a2866ccfcc5359fb4ca36ffa23729e38fa0 1 parent 25b4471
@dogmatic69 dogmatic69 authored
Showing with 7 additions and 2 deletions.
  1. +7 −2 lib/Cake/Utility/Sanitize.php
View
9 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);
}
Please sign in to comment.
Something went wrong with that request. Please try again.