Skip to content
This repository
Browse code

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

  • Loading branch information...
commit 50333a2866ccfcc5359fb4ca36ffa23729e38fa0 1 parent 25b4471
Carl Sutton authored September 13, 2012

Showing 1 changed file with 7 additions and 2 deletions. Show diff stats Hide diff stats

  1. 9  lib/Cake/Utility/Sanitize.php
9  lib/Cake/Utility/Sanitize.php
@@ -150,10 +150,15 @@ public static function stripImages($str) {
150 150
  * Strips scripts and stylesheets from output
151 151
  *
152 152
  * @param string $str String to sanitize
153  
- * @return string String with <script>, <style>, <link>, <img> elements removed.
  153
+ * @return string String with <link>, <img>, <script>, <style> elements and html comments removed.
154 154
  */
155 155
 	public static function stripScripts($str) {
156  
-		$regex = '/(<link[^>]+rel="[^"]*stylesheet"[^>]*>|<img[^>]*>|style="[^"]*")|<script[^>]*>.*?<\/script>|<style[^>]*>.*?<\/style>|<!--.*?-->/is';
  156
+		$regex =
  157
+			'/(<link[^>]+rel="[^"]*stylesheet"[^>]*>|' .
  158
+			'<img[^>]*>|style="[^"]*")|' .
  159
+			'<script[^>]*>.*?<\/script>|' .
  160
+			'<style[^>]*>.*?<\/style>|' .
  161
+			'<!--.*?-->/is';
157 162
 		return preg_replace($regex, '', $str);
158 163
 	}
159 164
 

0 notes on commit 50333a2

Please sign in to comment.
Something went wrong with that request. Please try again.