Skip to content

Commit

Permalink
Merge pull request #7 from vysokeskoly/fix/find-html-tag
Browse files Browse the repository at this point in the history
Fix finding a similiar html tag
  • Loading branch information
MortalFlesh authored Nov 29, 2023
2 parents 7123b9f + 48f5fdf commit 55416a7
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 55416a7

Please sign in to comment.