From fb8b118234ca0d2c6eba14fb2b9e495d7733b66d Mon Sep 17 00:00:00 2001 From: Pongpanot Chuaysakun Date: Thu, 22 Mar 2018 01:47:43 +0700 Subject: [PATCH 1/5] update version --- composer.json | 14 +++++++++----- tests/CollectionTest.php | 3 ++- tests/ContentTest.php | 4 ++-- tests/DomTest.php | 3 ++- tests/Node/ChildrenTest.php | 3 ++- tests/Node/HtmlTest.php | 3 ++- tests/Node/ParentTest.php | 3 ++- tests/Node/TagTest.php | 4 ++-- tests/Node/TextTest.php | 3 ++- tests/Options/CleanupTest.php | 3 ++- tests/Options/PreserveLineBreaks.php | 3 ++- tests/Options/StrictTest.php | 4 ++-- tests/Options/WhitespaceTextNodeTest.php | 4 ++-- tests/OptionsTest.php | 3 ++- tests/SelectorTest.php | 3 ++- tests/StaticDomTest.php | 3 ++- 16 files changed, 39 insertions(+), 24 deletions(-) diff --git a/composer.json b/composer.json index 96c16d2f..2bab575e 100644 --- a/composer.json +++ b/composer.json @@ -1,5 +1,5 @@ { - "name": "paquettg/php-html-parser", + "name": "muchrm/php-html-parser", "type": "library", "version": "1.7.0", "description": "An HTML DOM parser. It allows you to manipulate HTML. Find tags on an HTML page with selectors just like jQuery.", @@ -11,17 +11,21 @@ "name": "Gilles Paquette", "email": "paquettg@gmail.com", "homepage": "http://gillespaquette.ca" + }, + { + "name": "Pongpanot Chuaysakun", + "email": "muchrm.me@gmail.com" } ], "require": { - "php": ">=5.6", + "php": "^5.6 || ^7.0", "ext-mbstring": "*", "paquettg/string-encode": "~0.1.0" }, "require-dev": { - "phpunit/phpunit": "~5.7.0", - "satooshi/php-coveralls": "~1.0.0", - "mockery/mockery": "~0.9.0" + "phpunit/phpunit": "~7", + "satooshi/php-coveralls": "~2.0.0", + "mockery/mockery": "~1" }, "autoload": { "psr-0": { diff --git a/tests/CollectionTest.php b/tests/CollectionTest.php index 6204f954..b2a7ee39 100644 --- a/tests/CollectionTest.php +++ b/tests/CollectionTest.php @@ -4,8 +4,9 @@ use PHPHtmlParser\Dom\HtmlNode; use PHPHtmlParser\Dom\Tag; use PHPHtmlParser\Dom\Collection; +use PHPUnit\Framework\TestCase; -class CollectionTest extends PHPUnit_Framework_TestCase { +class CollectionTest extends TestCase { public function testEach() { diff --git a/tests/ContentTest.php b/tests/ContentTest.php index 0a3fb8e3..77ca4a09 100644 --- a/tests/ContentTest.php +++ b/tests/ContentTest.php @@ -1,8 +1,8 @@ Date: Thu, 22 Mar 2018 01:48:00 +0700 Subject: [PATCH 2/5] update preg_replace --- src/PHPHtmlParser/Dom.php | 34 +++++++++++----------------------- 1 file changed, 11 insertions(+), 23 deletions(-) diff --git a/src/PHPHtmlParser/Dom.php b/src/PHPHtmlParser/Dom.php index 22b56ec6..7f9e0f2c 100644 --- a/src/PHPHtmlParser/Dom.php +++ b/src/PHPHtmlParser/Dom.php @@ -470,47 +470,35 @@ protected function clean($str) // skip entire cleanup step return $str; } - // remove white space before closing tags - $str = mb_eregi_replace("'\s+>", "'>", $str); - $str = mb_eregi_replace('"\s+>', '">', $str); - + $str = preg_replace("#'\s+>#i", "'>", $str); + $str = preg_replace('#"\s+>#i', '">', $str); // clean out the \n\r $replace = ' '; if ($this->options->get('preserveLineBreaks')) { $replace = ' '; } $str = str_replace(["\r\n", "\r", "\n"], $replace, $str); - // strip the doctype - $str = mb_eregi_replace("", '', $str); - + $str = preg_replace("##i", '', $str); // strip out comments - $str = mb_eregi_replace("", '', $str); - + $str = preg_replace("##i", '', $str); // strip out cdata - $str = mb_eregi_replace("", '', $str); - + $str = preg_replace("##i", '', $str); // strip out