Skip to content

Commit 924a594

Browse files
committed
1 parent 4e13ad2 commit 924a594

File tree

3 files changed

+4
-3
lines changed

3 files changed

+4
-3
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2020
- Added tag attribute DTO.
2121
- Cleaned up the selector logic.
2222
- Fixed issue with greedy regex for charset detection.
23+
- Fixed bug causing infinite loops in some cases.
2324

2425
### Removed
2526
- Curl interface and curl implementation has been removed.

src/PHPHtmlParser/Content.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ public function copyUntil(string $string, bool $char = false, bool $escape = fal
164164
*
165165
* @return string
166166
*/
167-
public function copyUntilUnless(string $string, string $unless)
167+
public function copyUntilUnless(string $string, string $unless): string
168168
{
169169
$lastPos = $this->pos;
170170
$this->fastForward(1);

src/PHPHtmlParser/Dom.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -749,7 +749,7 @@ private function parseTag(): array
749749
do {
750750
$moreString = $this->content->copyUntilUnless('"', '=>');
751751
$string .= $moreString;
752-
} while (!empty($moreString));
752+
} while (strlen($moreString) > 0 && $this->content->getPosition() < $this->size);
753753
$attr['value'] = $string;
754754
$this->content->fastForward(1);
755755
$node->getTag()->setAttribute($name, $string);
@@ -760,7 +760,7 @@ private function parseTag(): array
760760
do {
761761
$moreString = $this->content->copyUntilUnless("'", '=>');
762762
$string .= $moreString;
763-
} while (!empty($moreString));
763+
} while (strlen($moreString) > 0 && $this->content->getPosition() < $this->size);
764764
$attr['value'] = $string;
765765
$this->content->fastForward(1);
766766
$node->getTag()->setAttribute($name, $string, false);

0 commit comments

Comments
 (0)