Skip to content

Commit

Permalink
Replaced preg_replace with mb_ereg_replace
Browse files Browse the repository at this point in the history
  • Loading branch information
paquettg committed Aug 16, 2015
1 parent 91c41e7 commit c550d79
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
20 changes: 10 additions & 10 deletions src/PHPHtmlParser/Dom.php
Original file line number Diff line number Diff line change
Expand Up @@ -344,30 +344,30 @@ protected function clean($str)
$str = str_replace(["\r\n", "\r", "\n"], ' ', $str);

// strip the doctype
$str = preg_replace("'<!doctype(.*?)>'is", '', $str);
$str = mb_eregi_replace("<!doctype(.*?)>", '', $str);

// strip out comments
$str = preg_replace("'<!--(.*?)-->'is", '', $str);
$str = mb_eregi_replace("<!--(.*?)-->", '', $str);

// strip out cdata
$str = preg_replace("'<!\[CDATA\[(.*?)\]\]>'is", '', $str);
$str = mb_eregi_replace("<!\[CDATA\[(.*?)\]\]>", '', $str);

// strip out <script> tags
$str = preg_replace("'<\s*script[^>]*[^/]>(.*?)<\s*/\s*script\s*>'is", '', $str);
$str = preg_replace("'<\s*script\s*>(.*?)<\s*/\s*script\s*>'is", '', $str);
$str = mb_eregi_replace("<\s*script[^>]*[^/]>(.*?)<\s*/\s*script\s*>", '', $str);
$str = mb_eregi_replace("<\s*script\s*>(.*?)<\s*/\s*script\s*>", '', $str);

// strip out <style> tags
$str = preg_replace("'<\s*style[^>]*[^/]>(.*?)<\s*/\s*style\s*>'is", '', $str);
$str = preg_replace("'<\s*style\s*>(.*?)<\s*/\s*style\s*>'is", '', $str);
$str = mb_eregi_replace("<\s*style[^>]*[^/]>(.*?)<\s*/\s*style\s*>", '', $str);
$str = mb_eregi_replace("<\s*style\s*>(.*?)<\s*/\s*style\s*>", '', $str);

// strip out preformatted tags
$str = preg_replace("'<\s*(?:code)[^>]*>(.*?)<\s*/\s*(?:code)\s*>'is", '', $str);
$str = mb_eregi_replace("<\s*(?:code)[^>]*>(.*?)<\s*/\s*(?:code)\s*>", '', $str);

// strip out server side scripts
$str = preg_replace("'(<\?)(.*?)(\?>)'s", '', $str);
$str = mb_eregi_replace("(<\?)(.*?)(\?>)", '', $str);

// strip smarty scripts
$str = preg_replace("'(\{\w)(.*?)(\})'s", '', $str);
$str = mb_eregi_replace("(\{\w)(.*?)(\})", '', $str);

return $str;
}
Expand Down
2 changes: 1 addition & 1 deletion src/PHPHtmlParser/Dom/TextNode.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class TextNode extends AbstractNode {
public function __construct($text)
{
// remove double spaces
$text = preg_replace('/\s+/', ' ', $text);
$text = mb_ereg_replace('\s+', ' ', $text);

$this->text = $text;
$this->tag = new Tag('text');
Expand Down

0 comments on commit c550d79

Please sign in to comment.