Skip to content

Commit 0efca91

Browse files
committed
Fixed paquettg#190 - Added gzip detection and decoding.
1 parent 8556ab2 commit 0efca91

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

composer.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@
1616
"require": {
1717
"php": ">=7.1",
1818
"ext-mbstring": "*",
19-
"paquettg/string-encode": "~1.0.0"
19+
"paquettg/string-encode": "~1.0.0",
20+
"ext-zlib": "*",
21+
"ext-curl": "*"
2022
},
2123
"require-dev": {
2224
"phpunit/phpunit": "^7.5.1",

src/PHPHtmlParser/Dom.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -513,6 +513,11 @@ protected function clean(string $str): string
513513
return $str;
514514
}
515515

516+
$is_gzip = 0 === mb_strpos($str, "\x1f" . "\x8b" . "\x08", 0, "US-ASCII");
517+
if ($is_gzip) {
518+
$str = gzdecode($str);
519+
}
520+
516521
// remove white space before closing tags
517522
$str = mb_eregi_replace("'\s+>", "'>", $str);
518523
$str = mb_eregi_replace('"\s+>', '">', $str);

0 commit comments

Comments
 (0)