Skip to content

Commit

Permalink
Fix finding a similiar html tag
Browse files Browse the repository at this point in the history
  • Loading branch information
MortalFlesh committed Nov 29, 2023
1 parent 7123b9f commit 48f5fdf
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

<!-- There is always Unreleased section on the top. Subsections (Added, Changed, Fixed, Removed) should be added as needed. -->
## Unreleased
- Fix finding a similar html tag

## 7.4.0 - 2023-10-25
- Encode html entities in `HtmlHelper` to prevent parse errors
Expand Down
2 changes: 1 addition & 1 deletion src/Service/HtmlHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public function findAllImages(string $content): array
private function findAllTags(string $tag, string $requiredAttr, string $content, callable $createTag): array
{
$mappedContent = str_replace("\n", self::EOL_PLACEHOLDER, $content);
preg_match_all(sprintf('/<%s(.*?)>/', $tag), $mappedContent, $matches);
preg_match_all(sprintf('/<%s( .*?)>/', $tag), $mappedContent, $matches);

return $this->mapMatches(
$this->mapEoLPlaceholders(array_pop($matches)),
Expand Down
4 changes: 4 additions & 0 deletions tests/Service/HtmlHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,10 @@ public function linksProvider(): array
'<div>content</div>',
[],
],
'with similar tag' => [
'<div><address>content</address></div>',
[],
],
'with one link' => [
'<div>content<a href="$$slovnik:prezencni-studium$$"></a></div>',
[
Expand Down

0 comments on commit 48f5fdf

Please sign in to comment.