mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
adjusting the way the regex is done so its easier to read
This commit is contained in:
parent
25b447149d
commit
50333a2866
1 changed files with 7 additions and 2 deletions
|
@ -150,10 +150,15 @@ class Sanitize {
|
||||||
* Strips scripts and stylesheets from output
|
* Strips scripts and stylesheets from output
|
||||||
*
|
*
|
||||||
* @param string $str String to sanitize
|
* @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) {
|
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);
|
return preg_replace($regex, '', $str);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue