about:benjie

Random learnings and other thoughts from an unashamed geek

PHP Preg_replace Segfault Fixed

| Comments

So I finally fixed the issue here, by replacing

Segfaults
1
2
<?php // For syntax highlighting
$data = preg_replace('/ '. trim($attrib) .'=(\w|\s|=|-|:|;|\/|\.|\?|&|,|#|!|\(|\)|\+|{|})*/i', '', $data);

with

Doesn’t segfault
1
2
<?php // For syntax highlighting
$data = preg_replace('/ '. trim($attrib) .'=[\w\s=:;\/.?&,#!()\+{}-]*/i', '', $data);

Back to work I go.

Comments